latest Post

C + + part 7 ( destructor )





So hey guys this the 7th part of the C+ + series and you good a good response on the other parts so i give links below .
part 1(static variable and function)

part 2(friend function)

part 3(reference variable)

part 4(constructor - default)

part 5(constructor - paramaterized constructor)

part 6(constructor - copy constructor)

Syllabus of the C + +

This is part is all about the destructor the opposite of the constructor and thus you understand what thus this do and for more stay tuned and if not then also stay tuned with me on the destructor .
The last 3 parts are all about the constructor so if you want to see then they are below (links) and i also recommend you to see them first for the better understanding.
So let's go.................................................................................................................................................


DESTRUCTOR 

Destructor is what that is opposite of the constructor that' what everyone knows that studied or not constructor so this is not i want to say here that's something else .

Destructor is the which is used to delocate the memory whenever no longer needed .

Destructor should have same name as class name but should be prefixed by ~ sign .

Constructor calls from up to down fashion and destructor calls down to up fashion .   

Let's to CODE..........................................................................................................................................

#include<iostrem.h>
#include<conio.h>

class abc
{
              public :
                             abc ( )
                             {
                                           cout<<"\n constructor" ;
                             }
                             ~abc ( )
                             {
                                           cout<<"\n destructor" ;
                             }
};
void main ( )
{
                       cout<<"\n =+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=" ;
                       abc a ;
                       {
                                abc b ;
                       }
                        abc c ;
                        getch( ) ;
}
 this program is to test the constructor and destructor can work together and the destructor can work also.
if you have any problem with any article write in the comment box and if there is no reply then contact me.
let's meet in the another article...............................................................................................................       

About hack guru

hack guru
Recommended Posts × +

0 comments:

Post a Comment