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 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 a destructor? Destructor is an instance member function which is invoked automatically whenever an object is going to be destroyed. Meaning, a destructor is… Read More
Destructors with the access modifier as private are known as Private Destructors. Whenever we want to prevent the destruction of an object, we can make… 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

Start Your Coding Journey Now!