class testint {public: testint(); testint(int b); //testint(testint& another); ~testint();private: int i;};testint::testint(){ cout<<"construct"<<endl;}testint::testint(int b):i(b){ cout<<"construct by " << i<<endl;}testint::~testint(){ cout<<"destruct i is "<<i<<endl;}///testint play(testint a){ return a;}int main(int argc, char* argv[]){ //printf("Hello World!\n"); testint t1 = play(4); testint t2 = play(5); testint t3 = play(t1); return 0;}///输出结果为:construct by 4destruct i is 4construct by 5destruct i is 5destruct i is 4destruct i is 4destruct i is 5destruct i is 4///
相关资源:构造函数c语言