- Trending Categories
- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- MS Excel
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP
- Physics
- Chemistry
- Biology
- Mathematics
- English
- Economics
- Psychology
- Social Studies
- Fashion Studies
- Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Pure virtual destructor in C++
The pure virtual destructor is possible in C++. If a class contains pure virtual destructor it is must to provide a function body for the pure virtual destructor.
Example Code
#include <iostream> using namespace std; class B { public: virtual ~B()=0; // Pure virtual destructor }; B::~B() { std::cout << "Pure virtual destructor is called"; } class D : public B { public: ~D() { cout << "~D() is executed"<<endl; } }; int main() { B *bptr=new D(); delete bptr; return 0; }
Output
~D() is executed Pure virtual destructor is called
Advertisements