最贊回答 / 進擊的吃貨
構造方法不寫具體方法也要加上{},視頻演示的時候,因為類是定義在頭文件中的,所以只需要規定方法名和參數,具體在另外一個文件中實現該方法Student(){} ;? ? Student(string _name){};? ? Student(const Student&stu){};? ? ~Student(){};
2019-06-26
最新回答 / weixin_慕桂英8445840
通過了#include <iostream>#include <string>#include<stdlib.h>using namespace std;class Student{public: // 定義數據成員封裝函數setName() Student(); Student(string name); void setName(string _name); string getName(); Student(const Student &tea); ~St...
2019-05-29
最贊回答 / 慕UI1379366
可以類內定義函數啊,編譯器會把它當做“內聯函數”首先執行(前提是類內定義的那個函數較為簡單。你這個程序可以運行啊,結果也沒什么毛病,你是想問什么呢??
2019-05-17
最贊回答 / 慕工程8098467
Teacher t1;是實例化了一個對象t1,Teacher()函數是Teacher類的構造函數,而在實例化對象的同時類的構造函數會自動執行,
2019-05-14
最贊回答 / 慕移動7594754
這是一個二義性的問題Base2自己有一個b 然后又從Base1繼承了一個b?當你d.b=2的時候 編譯器不知道是Base1::b=2還是Base2::b=2
2019-05-08
最新回答 / weixin_慕工程1276151
#include<iostream>#include<math.h>using namespace std;class location{public :? ? ? location (double _x,double _y)? ? ? {? ? ? ? ? ? x=_x;? ? ? ? ? ? y=_y;? ? ? }? ? ? double getx()? ? ? {? ? ? ? ? ? return x;? ? ? }? ? ? double gety()? ? ? {? ...
2019-04-22