源码:
#include <iostream>
using namespace std;
class AA
{
public:
AA(int a){x=a;cout<<"有参构造函数被调用!\n";}
AA(const AA & a){x=a.x;cout<<"拷贝构造函数被调用!\n";}
AA fun1(AA a){AA t(a.x+5);cout<<t.x<<endl;return t;}
AA *fun2(AA a){AA t(a.x+6);cout<<t.x<<endl;return &t;}
AA &fun3(AA a){AA t(a.x+7);cout<<t.x<<endl;return t;}
int x;
};
void main()
{
AA *pa,a(3),&b=a,c(b);cout<<c.x<<endl;
pa=&a;pa->fun1(c);pa->fun2(c);(*pa).fun3(c);
}