读书人

请问大师小弟我的这个类错在哪里

发布时间: 2013-07-11 15:38:46 作者: rapoo

请教大师,我的这个类错在哪里?

我写了个类,带默认参数,但提示出错。

头文件ceshi.h
class CMath
{
private:

public:
static int x,y;
CMath();
CMath(int a,int b);

~CMath();

int add(int a=x,int b=y);
int minus(int a=x,int b=y);

};

源文件ceshi.cpp
#include "stdafx.h" // 在MFC里调用需要添加此句
#include "ceshi.h"


CMath::CMath()
{
x=0;
y=0;
}
CMath::CMath(int a,int b)
{
x=a;
y=b;
}
CMath::~CMath()
{
}
int CMath::add(int a,int b)
{
return a+b;
}
int CMath::minus(int a,int b)
{
return a-b;
}

提示 :
unresolved external symbol "public: static int CMath::y" (?y@CMath@@2HA)
unresolved external symbol "public: static int CMath::x" (?x@CMath@@2HA)

[解决办法]
http://zhidao.baidu.com/question/411539802.html
[解决办法]
int CMath::x=0;
int CMath::y=0;
加上这个。
[解决办法]
是的。我测试了。

读书人网 >VC

热点推荐