class CSnakeRect:public CObject
{
public:
int x;
int y;
int orient;
CRect r;
CSnakeRect();
CSnakeRect(const CSnakeRect&);
CSnakeRect operator =(const CSnakeRect &c)
{
x=c.x;
y=c.y;
orient=c.orient;
r=c.r;
return *this;
}
};CSnakeRect::CSnakeRect(const CSnakeRect& right)
{
x=right.x;
y=right.y;
orient=right.orient;
r=right.r;
}基础打得不好呀,请各位大侠援手,错误提示如下:Linking...
snakeDlg.obj : error LNK2005: "public: __thiscall CSnakeRect::CSnakeRect(class CSnakeRect const &)" (??0CSnakeRect@@QAE@ABV0@@Z) already defined in snake.obj
snakeDlg.obj : error LNK2001: unresolved external symbol "public: __thiscall CSnakeRect::CSnakeRect(void)" (??0CSnakeRect@@QAE@XZ)
Debug/snake.exe : fatal error LNK1120: 1 unresolved externals
Error executing link.exe.
{
public:
int x;
int y;
int orient;
CRect r;
CSnakeRect();
CSnakeRect(const CSnakeRect&);
CSnakeRect operator =(const CSnakeRect &c)
{
x=c.x;
y=c.y;
orient=c.orient;
r=c.r;
return *this;
}
};CSnakeRect::CSnakeRect(const CSnakeRect& right)
{
x=right.x;
y=right.y;
orient=right.orient;
r=right.r;
}基础打得不好呀,请各位大侠援手,错误提示如下:Linking...
snakeDlg.obj : error LNK2005: "public: __thiscall CSnakeRect::CSnakeRect(class CSnakeRect const &)" (??0CSnakeRect@@QAE@ABV0@@Z) already defined in snake.obj
snakeDlg.obj : error LNK2001: unresolved external symbol "public: __thiscall CSnakeRect::CSnakeRect(void)" (??0CSnakeRect@@QAE@XZ)
Debug/snake.exe : fatal error LNK1120: 1 unresolved externals
Error executing link.exe.
解决方案 »
- 百分提问 做过网络监测的大侠请进
- 设计问题:如何调用一个DLL接口
- 实现VISIO 智能连接线功能 求算法
- ************* 见鬼了,非常怪的问题, 请高手来解答, ******************
- 如何做出漂亮的软件??
- 在ActiveX控件中如何访问IE浏览器上的对象?
- 大家一起推荐:你知道哪些好的HTTP/FTP或rtsp/wmv下载类?
- 什么是对象的容器?
- 贴子为什么被删(标题为:马甲放分(CADme)问题点数为2103的贴子).信誉分被扣成 -5
- CHtmlView::Navigate2()使用求救。急!急!!!希望高手指教!!!多谢!!
- 关于文档序列化的问题,求高手帮助!
- 菜鸟求解:vc的image空间,如何利用位图ID来加载位图?
另外能不能把你其他的代码也贴出来,因为链接出错信息提示你的默认构造和拷贝构造也有问题。
哈to楼上 operatoer = 就是返回 *this啊
CSnakeRect operator =(const CSnakeRect &c)
{
x=c.x;
y=c.y;
orient=c.orient;
r=c.r;
return *this;
}
-- >> CSnakeRect& operator =(const CSnakeRect &c)
CSnakeRect::CSnakeRect(const CSnakeRect& right)
{
x=right.x;
y=right.y;
orient=right.orient;
r=right.r;
}
改成为类定义内实现就通过了,改完后的代码如下:
class CSnakeRect:public CObject
{
public:
int x;
int y;
int orient;
CRect r;
CSnakeRect()
{
x=0;
y=0;
orient=1;
r=CRect(0,0,1,1);
}
CSnakeRect(const CSnakeRect &right)
{
x=right.x;
y=right.y;
orient=right.orient;
r=right.r;
}
CSnakeRect operator =(const CSnakeRect &c)
{
x=c.x;
y=c.y;
orient=c.orient;
r=c.r;
return *this;
}
};现在LINK通过了,但是真是不清楚为什么?为什么???????????????????