#include <iostream>
#include <string>
using namespace std;
class Student
{
public:
int m_iAge;
string m_strName ;
};
int main()
{
Student stu;
stu.m_strName = "慕课网";
stu.m_iAge = 2;
cout << stu.m_strName << "年龄为: " << stu.m_iAge<< endl;
return 0;
}
#include <string>
using namespace std;
class Student
{
public:
int m_iAge;
string m_strName ;
};
int main()
{
Student stu;
stu.m_strName = "慕课网";
stu.m_iAge = 2;
cout << stu.m_strName << "年龄为: " << stu.m_iAge<< endl;
return 0;
}
Student stu1();//表示声明一个叫stu1的无参函数,该函数返回值是一个Student对象,这里造成歧义,所以在栈中实例化一个对象应该用Student stu1;
2018-01-19