#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