

- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- 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
- Related Questions & Answers
- Why do we need a pure virtual destructor in C++?
- Virtual Destructor in C++
- Difference Between Virtual and Pure Virtual Function
- Pure Virtual Functions and Abstract Classes in C++
- Difference between a virtual function and a pure virtual function in C++
- Why is a C++ pure virtual function initialized by 0?
- Private Destructor in C++
- Pure ALOHA
- Pure Function in C++
- Pure Component in React.js
- Difference Between Constructor and Destructor
- Order of Constructor/ Destructor Call in C++
- Smooth Scrolling with Pure CSS
- What are pure discount bonds?
- How does the destructor method __del__() work in Python?
Advertisements