为了账号安全,请及时绑定邮箱和手机立即绑定

求解 很疑惑

求解 很疑惑

C++
已天涯 2017-08-22 15:04:39
#include <iostream>#include <string>using namespace std;/**  * 定义类:Student  * 数据成员:名字、年龄  */  class student{public:    // 定义数据成员名字 m_strName 和年龄 m_iAge    int m_strName;    string     m_iAge;};int main(){    // 实例化一个Student对象stu    student stu;    // 设置对象的数据成员    stu.m_strName = "慕课网";    stu.m_iAge = 2;        // 通过cout打印stu对象的数据成员    cout << stu.m_strName<< " " << stu.m_Age<< endl;    return 0;}把int  string 还换位置为啥就不行?
查看完整描述

2 回答

?
snowmanJS

TA贡献89条经验 获得超53个赞

cout<<stu.m_strName<<" "<<stu.m_iAge<<endl;
注意:不是m_Age

查看完整回答
反对 回复 2017-08-23
?
Tpsopf

TA贡献1条经验 获得超0个赞

变量类型写错了,打印输出的时候年龄变量写错了

查看完整回答
反对 回复 2017-08-23
?
Uchiha_Obito

TA贡献3条经验 获得超0个赞


哪里换位置,说清楚啊

查看完整回答
反对 回复 2017-08-22
  • 2 回答
  • 0 关注
  • 2000 浏览

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信