源程序:
#include <iostream>
using namespace std;
class B
{
private:
int data;
public:
B()
{
cout << "构造函数B" << endl;
}
B(int a)
{
data = a;
cout << "带1个参数的构造函数B" << endl;
}
B play(B b)
{
return b;
}
~B()
{
cout << "析构函数B" << endl;
}
};
int main()
{
B temp;
temp.play(5);
system("pause");
return 1;
}
运行结果: