亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
兩倍速的同志專門點回正常速度。。。。我信你個鬼啊
在圖書館因為按空格鍵太快太響已被逮捕
這題應該選C
老師,您上課的條理清晰,講解細致,而且很精煉不啰嗦,關鍵是這么好的入門視頻還是免費的!想對您說一句:謝謝您!辛苦了!
視頻 5:21 , string s1 = "hello" 少了個分號吧。
視頻幀數低所以沒看到吧哈哈哈
感覺這個視頻不是針對零基礎的
C:
cout << stu->getName() << endl;
delete stu;
return 0;
}
B:
private:
string m_strName="世間第一帥氣人";
};
Student::Student(string name) :m_strName(name) {}
void Student::setName(string name) {
m_strName = name;
}
string Student::getName() {
return m_strName;
}
int main(void) {
Student *stu = new Student;
stu->setName("慕課網");
A:
#include <iostream>
#include <string>
using namespace std;
class Student {
public:
Student(string name) ;
Student(const Student & stuc) {};
Student() {};
~Student() {};
void setName(string name);
string getName();
頭文件B:
int getMax();
private:
string m_strName;
int m_iAge;
const int m_iMax = 1;
};
頭文件A:
#include"string"
#include"iostream"
using namespace std;
class Student {
public:
Student(string name = "小白", int Age = 1, int Max = 100);//初始化構造函數 構造函數——用以初始化
Student(const Student &stu);//拷貝構造函數
void setName(string name);
string getName();
void setAge(int Age);
int getAge();
源2B:
void Student::setName(string name) {
m_strName = name;
}
string Student::getName() {
return m_strName;
}
void Student::setAge(int Age) {
m_iAge = Age;
}
int Student::getAge() {
return m_iAge;
}
int Student::getMax() {
return m_iMax;
}
源2A:
#include"標頭.h"
Student::Student(string name, int Age, int Max) :m_strName(name), m_iAge(Age), m_iMax(Max) { cout << "you used initialization_code"<<endl; } //初始化列表
Student::Student(const Student & stu) { cout << "you used copy_code"<<endl; }//拷貝構造函數
源1:
#include"標頭.h"
int main() {
Student *str = new Student;//初始化——指針方式
Student stu1("小白", 12, 150);//初始化
str->setName("慕課網");
Student stu2 = stu1;//測試拷貝函數部分
cout << stu1.getName() << " \t " << str->getAge() << "\t" << str->getMax();
delete str;
str = NULL;
return 0;
}
課程須知
本課程是C++初級課程 需要熟練掌握C++語言基礎語法
老師告訴你能學到什么?
1、類的定義與對象實例化 2、string類型及屬性封裝 3、類外定義 4、構造函數與初始化列表 5、析構函數

微信掃碼,參與3人拼團

微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號

友情提示:

您好,此課程屬于遷移課程,您已購買該課程,無需重復購買,感謝您對慕課網的支持!

本次提問將花費2個積分

你的積分不足,無法發表

為什么扣積分?

本次提問將花費2個積分

繼續發表請點擊 "確定"

為什么扣積分?

舉報

0/150
提交
取消