试着用多文件结构去写程序,编译出现 undefined reference to......的错误 怎么也解决
不了,不知道是哪里出现了问题 ,希望大家能帮忙看一下
class add
{
public:
int x;
int y;
void get(int newx,int newy);
int Add();
};
#include"add.h"
#include"iostream"
using namespace std;
void add::get(int newx,int newy)
{
x=newx;
y=newy;
}
int add::Add()
{
return this.x+this.y;
}
#include
#include"add.h"
using namespace std;
int main()
{
add A;
A.get(1,2);
cout<<A.Add();
return 0;
}
循环引用了,你的.h文件加上#progma once