demo.cpp的文件開頭加 #include "Teacher.h"也會報 "error LNK2019: 無法解析的外部符號..." 的錯誤,但是改為#include"Teacher.cpp"就能編譯通過
2016-10-25
老師太棒啦,每個知識點聽完之后不僅能夠知其然,還能知其所以然,更有助于消化理解。希望多多講解一些實例,編程演示什么噠。謝謝james老師~
class Student
{
public:
void setName(string _name)
{
m_strName = _name;
}
string getName()
{
return m_strName;
}
private:
string m_strName;
};
int main(void)
{
Student *str = new Student;
str->setName("慕課網");
cout << str->getName() << endl;
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(void)
{
Student *str = new Student;
str->setName("慕課網");
cout << str->getName() << endl;
delete str;
str = NULL;
return 0;
}