错误了。。: error C2061: 语法错误: 标识符“string_name
每次都是 : error C2061: 语法错误: 标识符“string_name
我完全按照老师讲的打的。
每次都是 : error C2061: 语法错误: 标识符“string_name
我完全按照老师讲的打的。
2015-06-16
#include <iostream>
#include <stdlib.h>
#include <string>
using namespace std;
/*************************************************/
/* 数据的封装
定义一个Student类,含有如下信息
1.姓名:name
2.性别:gander
3.学分(只读):score
4.学习:study
***************************************************/
class Student
{
public:
void setName(string _name)
{
m_strName = _name;
}
string getName()
{
return m_strName;
}
void setGender(string _gender)
{
m_strGender =_gender;
}
string getGender()
{
return m_strGender;
}
int getScore()
{
return m_iScore;
}
void initScore()
{
m_iScore = 0;
}
void study(int _score)
{
m_iScore += _score;
}
private:
string m_strName;
string m_strGender;
int m_iScore;
};
int main(void)
{
Student stu;
stu.initScore();
stu.setName("zhangsan");
stu.setGender("女");
stu.study(5);
stu.study(3);
cout << stu.getName() << " " << stu.getGender() << " " << stu.getScore() << endl;
system("pause");
return 0;
}
#include <iostream>
#include <stdlib.h>
#include <cstring>
using namespace std;
/*************************************************/
/* 数据的封装
定义一个Student类,含有如下信息
1.姓名:name
2.性别:gander
3.学分(只读):score
4.学习:study
***************************************************/
class Student
{
public:
void setName(string_name)
{
m_strName = _name;
}
string getName()
{
return m_strName;
}
void setGender(string_gender)
{
m_strGender = gender;
}
string getGender()
{
return m_strGender;
}
int getScore()
{
return m_iScore;
}
void initScore()
{
m_iScore = 0;
}
void study(int_score)
{
m_iSore += _score;
}
private:
string m_strName;
string m_strGender;
int m_iScore;
};
int main(void)
{
Student stu;
stu.initScore();
stu.setName("zhangsan");
stu.setGender("女");
stu.study(5);
stu.study(3);
cout << sut.getName() << " " << stu.getGender() << " " << stu.getScore() << endl;
system("pause");
}
举报