demo.cpp的头文件为:#include <iostream>
#include <stdlib.h>
#include <string>
#include "teacher.cpp"
teacher.h的头为
#include <string>
using namespace std;
tercher.cpp的头为:
#include "teacher.h"
已经在Mac下使用sublime和vscode还有g++测试通过
#include <stdlib.h>
#include <string>
#include "teacher.cpp"
teacher.h的头为
#include <string>
using namespace std;
tercher.cpp的头为:
#include "teacher.h"
已经在Mac下使用sublime和vscode还有g++测试通过
2017-03-14
最赞回答 / 慕运维9949243
因为后面定义数据成员时已定义了char *m_pName;所以在构造函数中没有必要写成char *m_pName=new char[20];如果有帮助希望采纳
2017-03-13
class Student
{
public:
Student(){}
Student(string _name){}
Student(const Student& stu) {}
~Student()
{
}
void setName(string _name)
{
m_strName = _name;
}
string getName()
{
return m_strName;
}
private:
string m_strName;
};
{
public:
Student(){}
Student(string _name){}
Student(const Student& stu) {}
~Student()
{
}
void setName(string _name)
{
m_strName = _name;
}
string getName()
{
return m_strName;
}
private:
string m_strName;
};