H1.h
class Student
{
private:
int number;
public:
void display();
void set(int);
};
H1.cpp
#include <iostream>
#include "H1.h"
using namespace std;
void Student::display()
{
cout <<number;
}
void Student::set(int num)
{
number=num;
}
主函数
#include <iostream>
#include "H1.h"
using namespace std;
int main()
{
Student st1;
st1.set(1);
st1.display();
return 0;
}
编译可以通过 但连接的时候出现以下问题:
--------------------Configuration: Cpp1 - Win32 Debug--------------------
Linking...
Cpp1.obj : error LNK2001: unresolved external symbol "public: void __thiscall Student::display(void)" (?display@Student@@QAEXXZ)
Cpp1.obj : error LNK2001: unresolved external symbol "public: void __thiscall Student::set(int)" (?set@Student@@QAEXH@Z)
Debug/Cpp1.exe : fatal error LNK1120: 2 unresolved externals
Error executing link.exe.
Cpp1.exe - 3 error(s), 0 warning(s)
请大家帮帮忙啊~我不晓得哪里有问题...