#include"string"
#include"iostream"
using namespace std;
class Student {
public:
Student(string name = "小白",int Age=1,int Max=100);//構(gòu)造函數(shù)初始化
void setName(string name);
string getName();
void setAge(int Age);
int getAge();
int getMax();
private:
string m_strName;
int m_iAge;
const int m_iMax
#include"iostream"
using namespace std;
class Student {
public:
Student(string name = "小白",int Age=1,int Max=100);//構(gòu)造函數(shù)初始化
void setName(string name);
string getName();
void setAge(int Age);
int getAge();
int getMax();
private:
string m_strName;
int m_iAge;
const int m_iMax
2019-01-25
Student::Student(string name,int Age,int Max) :m_strName(name), m_iAge(Age),m_iMax(Max){} //初始化列表
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;
}
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;
}
2019-01-25
DEMO1:
#include"標(biāo)頭.h"
int main() {
Student *str = new Student;
Student stu1("小白", 12, 150);
str->setName("慕課網(wǎng)");
cout << stu1.getName() << " \t " << str->getAge() << "\t" << str->getMax();
delete str;
str = NULL;
return 0;
}
#include"標(biāo)頭.h"
int main() {
Student *str = new Student;
Student stu1("小白", 12, 150);
str->setName("慕課網(wǎng)");
cout << stu1.getName() << " \t " << str->getAge() << "\t" << str->getMax();
delete str;
str = NULL;
return 0;
}
2019-01-25
class Student {
public:
void setName(string name) {
m_strName = name;
}
string getName() {
return m_strName;
}
private:
string m_strName;
};
int main() {
Student *str = new Student;
str->setName("慕課網(wǎng)");
cout << str->getName();
delete str;
str = NULL;
return 0;
}
public:
void setName(string name) {
m_strName = name;
}
string getName() {
return m_strName;
}
private:
string m_strName;
};
int main() {
Student *str = new Student;
str->setName("慕課網(wǎng)");
cout << str->getName();
delete str;
str = NULL;
return 0;
}
#include <iostream>
#include <string>
using namespace std;
int main(){
class student {
public:
string m_strName = "王發(fā)財(cái)";
int m_iAge = 199;
}stu;
stu.m_iAge = 2;
stu.m_strName = "慕課網(wǎng)";
cout << stu.m_iAge <<endl<< stu.m_strName << endl;
}
#include <string>
using namespace std;
int main(){
class student {
public:
string m_strName = "王發(fā)財(cái)";
int m_iAge = 199;
}stu;
stu.m_iAge = 2;
stu.m_strName = "慕課網(wǎng)";
cout << stu.m_iAge <<endl<< stu.m_strName << endl;
}
p[i]->這個(gè)確實(shí)不符合常規(guī) 數(shù)組是特殊的指針 當(dāng)指針加上【】 其性質(zhì)是和數(shù)組是一樣的 下面那位說p[i]->可以連用的 你是真惡心 不懂就亂指點(diǎn) 誘導(dǎo)他人理解錯(cuò)誤真可恥
2018-12-17