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; }
請高手幫忙解釋下這個函數(shù)的執(zhí)行順序。以及出現(xiàn) 的B Play( B b) 是什么意思?
慕田峪7331174
2023-01-12 15:11:00