class B{public:B(){cout<<"default constructor"<<endl;}~B(){cout<<"destructed"<<endl;}B(int i):data(i) //B(int) works as a converter ( int -> instance of B){cout<<"constructed by parameter " << data <<endl;}private:int data;};B Play( B b) {return b ;}(1) int main(int argc, char* argv[]) { B t1 = Play(5); B t2 = Play(t1); return 0; } (2) int main(int argc, char* argv[]) { B t1 = Play(5); B t2 = Play(10); return 0; }
1 回答
森林海
TA贡献2011条经验 获得超2个赞
1)B Play( B b):这是一个函数定义,接受类型为class B的参数b,返回类型为class B的值;
2)函数执行顺序:你在每个函数内加一个断点,断点单步调试就知道了。
- 1 回答
- 0 关注
- 76 浏览
添加回答
举报
0/150
提交
取消