帮忙看一下这样C++程序出错在哪里?
帮忙看一下是什么问题,文件student.h
#include <string>
using namespace std;
class student
{
public:
void display();
void set_value();
private:
int num;
string name;
char sex;
};
文件:student.cpp
#include <iostream>
#include "student.h"
void student:: display()
{
cout<<"num:"<<num<<endl;
cout<<"name:"<<name<<endl;
cout<<"sex:"<<sex<<endl;
}
void student::set_value()
{
cin>>num>>name>>sex;
}
文件:main.cpp
#include <iostream>
#include "student.h"
using namespace std;
int main()
{
student stud;
stud.set_value();
stud.display();
return 0;
}
运行之后出现:
--------------------Configuration: main - Win32 Debug--------------------
Compiling...
main.cpp
Linking...
main.obj : error LNK2001: unresolved external symbol "public: void __thiscall student::display(void)" (?display@student@@QAEXXZ)
main.obj : error LNK2001: unresolved external symbol "public: void __thiscall student::set_value(void)" (?set_value@student@@QAEXXZ)
Debug/main.exe : fatal error LNK1120: 2 unresolved externals
Error executing link.exe.
Creating browse info file...
main.exe - 3 error(s), 0 warning(s)