最贊回答 / 進(jìn)擊的吃貨
構(gòu)造方法不寫具體方法也要加上{},視頻演示的時候,因為類是定義在頭文件中的,所以只需要規(guī)定方法名和參數(shù),具體在另外一個文件中實現(xiàn)該方法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: // 定義數(shù)據(jù)成員封裝函數(shù)setName() Student(); Student(string name); void setName(string _name); string getName(); Student(const Student &tea); ~St...
2019-05-29
最贊回答 / 慕UI1379366
可以類內(nèi)定義函數(shù)啊,編譯器會把它當(dāng)做“內(nèi)聯(lián)函數(shù)”首先執(zhí)行(前提是類內(nèi)定義的那個函數(shù)較為簡單。你這個程序可以運(yùn)行啊,結(jié)果也沒什么毛病,你是想問什么呢??
2019-05-17
最贊回答 / 慕工程8098467
Teacher t1;是實例化了一個對象t1,Teacher()函數(shù)是Teacher類的構(gòu)造函數(shù),而在實例化對象的同時類的構(gòu)造函數(shù)會自動執(zhí)行,
2019-05-14
最贊回答 / 慕移動7594754
這是一個二義性的問題Base2自己有一個b 然后又從Base1繼承了一個b?當(dāng)你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