Skip to content

Tag Archives: cpp-destructor

In Object Oriented Programming, Objects are the instances of a class which has its own state(variables) and behavior(methods). Every class has two special methods related… Read More
1. What is destructor? Ans. Destructor is a member function which is called when an object is deleted/destroyed or goes out of scope. class String… Read More
This rule basically states that if a class defines one(or more) of the following, it should probably explicitly define all three, which are: destructor copy… Read More
Prerequisite: shared_ptr, Virtual Destructor As we know that, deleting a derived class object using a pointer to a base class that has a non-virtual destructor… Read More
What is destructor? Destructor is a member function which destructs or deletes an object. Syntax: ~constructor-name(); Properties of Destructor: Destructor function is automatically invoked when the… Read More
Also read : Can a constructor be private in C++ ? Predict the output of following programs.   CPP // CPP program to illustrate // Private Destructor… Read More
Predict the output of the below code snippet. #include <iostream> using namespace std;    int i;    class A { public:     ~A()     {         i=10;     }… Read More