3-3 构造函数的调用(高级)

来源:互联网 发布:地理探测器软件 编辑:程序博客网 时间:2024/06/05 17:03


#include<iostream>

using namespace std;
class A{
public:
    A()
    {
       cout<<"constructing an object of A"<<endl;
    }
    ~A()
    {
        cout<<"Destructing an object of A"<<endl;
    }
};
int main()
{
    cout<<"----begin main---"<<endl;
    A a;
    A *b;
    b = new A;
    delete(b);
    cout<<"*******"<<endl;
    A c;
    A d;
    cout<<"----end main---"<<endl;
    return 0;
}