New course! Every coder should learn Generative AI!
Try a free lesson0
constructor are use for to insilize value of the class object ...
destructor are use for destroy the value of constructor
in destructor use tild(~) symbol.
note :- the last object are created of constructor its. destroy first.
example...
class student
{
int rollno;
char name;
student()
{
cout<<rollno;
cout<<name;
}
~student()
{
cout<<" destroy constructor";
}
};
int main()
{
student s1,s2,s3;
getch();
return 0;
}
above program s3 object after destroy after s2 then last s1