係統粉 > 電腦問答 > 其他問答

已解決這段代碼哪錯了

提問者:懶栗子emperor  |  瀏覽次  |  提問時間:2017-01-28  |  回答數量:1

這段代碼哪錯了 本人初學c++,學繼承時,編了一段代碼,但是不知道哪出了問題,求高手解答 代碼: #include<iostream> #include<string> using namespace std; class student { public: student(string a,int b,char c) { name=a; age=b; sex=c; } student() {} void print() { cout<<\"name:\"<<name<<\"age:\"<<age<<\"sex:\"<<sex<<endl; } private: int age; string name; char sex; }; //公有繼承;student的派生類:student1 class student1:public student { public: student1(string a,int b,char c,string d):student(a,b,c),addr(d) v

已有1條答案
汾陽冉冉

汾陽冉冉

回答數:124  |  被采納數:130

解鈴還須係鈴人~
終於找到錯誤了
聲明student1構造函數時,addr(d)後沒有加{}
這麼小的錯誤,
寒哪~
2017-01-28 19:38:42
讚 12
相關問答
最新其他問答
解決方法