构造函数和析构函数程序举例

# include <iostream>
# include <string>
using namespace std;
class A
{
public:A()
       {
           cout<<"constructing an object of A"<<endl;
       }
       ~A()
       {
           cout<<"Destructing an object of A"<<endl;
       }
};
void temporary()
{
    A b;
}
int main()
{
    cout<<"----begin main---"<<endl;
    A a;
    temporary();
    cout<<"*******"<<endl;
    A c;
    A d;
    cout<<"----end main---"<<endl;
    return 0;
}

 

posted on 2013-10-25 16:20  随风浪子的博客  阅读(167)  评论(0编辑  收藏  举报

导航