#include<iostream>
using namespace std;
class Base
{
public:
Base(){
cout<<"hello"<<endl;
}
Base (int _a ):base(_a){ // 將a賦值給base
base++;
cout << base << endl;
}
Base (int _a ,float _b):base(_a),th(_b){
cout << base + th << endl;
}
Base (int _a ,float _b ,int _c):base(_a),th(_b),xh(_c){
cout << base + th + xh<< endl;
}
void fun0(){cout << base << endl;}
int base;
float th;
int xh;
};
int main(){
Base b; // 調用默認構造函數
Base t(10); // 調用帶參的構造函數的簡寫形式
t.fun0();
t.base=100;
t.fun0();
Base t1 =Base(100,88.12); // 調用帶參的構造函數
Base t2 =(10,100.12,20); //
}
注意:Base t2 =(10,100.12,20); 在烏班圖下輸出的結果為錯誤的。