1. 程式人生 > >建構函式 的呼叫的兩種方法

建構函式 的呼叫的兩種方法

#include <iostream>
using namespace std;
class A
{
private:


public:
    A()/*{cout<<"Constructing an object of A"<<endl;}*/;
    ~A()/*{cout<<"Destructing an object of A"<<endl;}*/;
};
A::A()
{
   cout<<"Constructing an object of A"<<endl;
}
A::~A()
{
   cout<<"Destructing an object of A"<<endl;
}
int main()
{
    A t1;
    A t2;
    return 0;
}