Introducing Radical.sh

Forget Code launches a powerful code generator for building API's

Destructor - Destroying the Object of the class in C++

Destructor:
A destructor is used to destroy the objects that have been created by a constructor.
Like constructor, the destructor is a member function whose name is the same as the class name but is preceded by a tilde.
eg:~ integer ( ) { }

#include <iostream>
 using namespace std;

class forgetcode
{
    public:
    forgetcode()
    {
        cout<<"\n objecvt is created ";
    }
    ~forgetcode()
    {
        cout<<"\n Object is destroyed";
    }
void display(int i)
{
    cout<<"\nobject is f"<<i;
}
        
};
    int main()
{
    forgetcode f1,f2,f3;
    f1.display(1);
    f2.display(2);
    f3.display(3);
return 0;
}