Program : Global Constructor and Destructor


#include <iostream.h>
#include<conio.h>
/*----------------------Class definition-------------------------*/
class sample
{
        int x;
    public:
        sample();
        int get_data() { return x; }
        ~sample();            // Destructor Declaration
};
sample::sample()
{
    cout << "Executing the Constructor...\n\n";
}
sample::~sample()            // Destructor Definition
{
    cout << "\nExecuting the Destructor...\n";
}
/*----------------------Definition ends here---------------------*/
sample globalobj;        // global object
void main(void)
{
    cout << "Entering MAIN...\n";
    cout << "x = " << globalobj.get_data() << "\n";
    cout << "Exiting MAIN...\n";
    getch();
}

1 comments:

Anonymous said...

wonderful post, very informative. I'm wondering why the opposite specialists of this sector don't understand this.
You must continue your writing. I'm sure, you've a great readers' base already!

my weblog :: cellulite treatment

Post a Comment

 
 
 
 


Copyright © 2012 http://codeprecisely.blogspot.com. All rights reserved |Term of Use and Policies|