最新回答 / KellyCayne
不一定是string型,看函數(shù)最后返回的數(shù)據(jù)類型,如果返回的是int數(shù)據(jù),則get函數(shù)是int類型,只有g(shù)et函數(shù)返回string型的數(shù)據(jù)時,它才是string類型
2019-11-06
最新回答 / 小御姐
Student stu1;Student stu3(stu1);//調(diào)用拷貝重載函數(shù),該語句的效果相當(dāng)于Student stu3
2019-10-22
最新回答 / tangl666
#include<iostream>#include<string.h>using namespace std;class Gun{?? ?public:?? ??? ?string type;?? ??? ?int ATK;?? ??? ?int GunCapacity;?? ??? ?int NowCapacity;?? ???? int?? ?Surplus;?? ? // or residue};int main(void){?? ?Gun *p = new Gun();?...
2019-09-27
最新回答 / weixin_慕絲3553261
這兩個函數(shù),只是在創(chuàng)建對象時 自動調(diào)用的,里面的內(nèi)容,你可以自己定義,但是,無論里面有沒有內(nèi)容,它都會在對象被創(chuàng)建時自動調(diào)用。有內(nèi)容,他就在對象被創(chuàng)建時去執(zhí)行。
2019-09-15
最新回答 / 慕數(shù)據(jù)0038314
#include <iostream>#include <string>using namespace std;class Student {string m_strName;int m_iAge;};int main(){Student * p=new student();stu->m_strName="慕課網(wǎng)";stu->m_iAge=2;cout <<"student name is: "<<stu->m_strName<<...
2019-08-31
最新回答 / lazypiggy
直接Teacher t2的話調(diào)用構(gòu)造函數(shù),Teacher t2(t1)調(diào)用的是拷貝構(gòu)造函數(shù)吧。
2019-08-15
最贊回答 / int程序小白
析構(gòu)函數(shù)里delete釋放的對象需要是類的數(shù)據(jù)成員,而且需要在構(gòu)造函數(shù)或者在其他調(diào)用過的函數(shù)里面為他開辟了空間,才能在析構(gòu)函數(shù)內(nèi)使用delete釋放
2019-08-12
最新回答 / qq_慕姐335276
int表示一個整型,用它來定義的函數(shù)必須要返回一個整數(shù),要用return;而void型定義的函數(shù)不需要返回任何值,將void換為int型的不同只是要返回一個整數(shù)而已,不影響正常使用
2019-08-10
最新回答 / 晴空92
http://c.biancheng.net/view/2235.htmlC++?中保留了C語言的 struct 關(guān)鍵字,并且加以擴(kuò)充。在C語言中,struct 只能包含成員變量,不能包含成員函數(shù)。而在C++中,struct 類似于 class,既可以包含成員變量,又可以包含成員函數(shù)。C++中的 struct 和 class 基本是通用的,唯有幾個細(xì)節(jié)不同:使用 class 時,類中的成員默認(rèn)都是 private 屬性的;而使用 struct 時,結(jié)構(gòu)體中的成員默認(rèn)都是 public 屬性的。class ...
2019-08-07