#include<stdafx.h>
#include<iostream.h>
class test
{int x;
public :
test()
{cout<<"建構式被呼叫\n"<<endl;
x=0;}
voidshow()
{coudt<<"x="<<x<<endl;}
};
int main()
{test obj1,obj2;
obj1.show();
obj2.show();
return 0;
}
求問:在我認為輸出應該是
建構式被呼叫
x=0
建構式被呼叫
x=0
但是習題上寫的先是兩個函式被呼叫,x=0為一塊,求解
uj5u.com熱心網友回復:
test obj1,obj2;這個時候就呼叫了兩次建構式。
轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/189723.html
標籤:C++ 語言
上一篇:使用vc編譯運行,輸入資料按回車總是需要多輸入一個資料才能進行下一步
下一篇:這個流程圖怎么畫啊
