الأربعاء، 18 ديسمبر 2013

دوال البناء والهدم.txt

#include<iostream.h>
class createAndDestroy
{
private:
int date ;
public:
 createAndDestroy(int);
~createAndDestroy();
};
createAndDestroy::createAndDestroy(int valu)
{
date=valu ;
cout<<"object"<<date<<"Constructor\t";
}
createAndDestroy::~createAndDestroy()
{
cout<<"object"<<date<<"destructor"<<endl;
}
void create();
createAndDestroy first(1);
int main()
{
cout<<"global object before main"<<endl;
createAndDestroy  second(2);
cout<<"local automatic in main"<<endl;
static createAndDestroy third(3);
cout<<"local static in main"<<endl;
create();
createAndDestroy fourth (4);
cout<<"local aotumatic in main"<<endl;
return 0 ;
}
void create()
{
createAndDestroy fifth(5);
cout<<"Local aotumatic in Create\n";
static createAndDestroy sixth(6);
cout<<"Local static in Create\n";
createAndDestroy seventh(7);
cout<<"Local aotumatic in Create\n";
}

0 التعليقات:

إرسال تعليق

Twitter Delicious Facebook Digg Stumbleupon Favorites More