关于undefined reference to 问题

towdney 2008-05-27 03:54:29
ab.h文件有这么一段定义
class Matrix : public GeneralMatrix // usual rectangular matrix
{
GeneralMatrix* Image() const; // copy of matrix
public:
Matrix() {}
~Matrix() {}
Matrix(int, int); // standard declaration
Matrix(const BaseMatrix&); // evaluate BaseMatrix
void operator=(const BaseMatrix&);
void operator=(Real f) { GeneralMatrix::operator=(f); }
void operator=(const Matrix& m) { operator=((const BaseMatrix&)m); }
...
...
};

主函数k.cpp 下面这段代码出错
Matrix xhat(n,1);
Matrix phi(n,n);
Matrix z(m,1);
错误信息是类似undefined reference to `Matrix::Matrix(int, int)'
请问如何解决?
...全文
512 6 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
lionc650 2008-05-27
  • 打赏
  • 举报
回复
不管在哪儿,Matrix(int,int)只定义没有实现吧..
Treazy 2008-05-27
  • 打赏
  • 举报
回复
[Quote=引用 4 楼 towdney 的回复:]
那么这个Matrix(int,int)的实现应该写在cpp文件,而不应该写在h头文件里?
[/Quote]

这个随便,对于构造函数你写在哪都是一样的!
towdney 2008-05-27
  • 打赏
  • 举报
回复
那么这个Matrix(int,int)的实现应该写在cpp文件,而不应该写在h头文件里?
帅得不敢出门 2008-05-27
  • 打赏
  • 举报
回复
[Quote=引用 2 楼 Treazy 的回复:]
Matrix(int, int); 的实现缺失!
[/Quote]

up 少了这个

Matrix(int, int)
{
............
}
Treazy 2008-05-27
  • 打赏
  • 举报
回复
Matrix(int, int); 的实现缺失!
towdney 2008-05-27
  • 打赏
  • 举报
回复
我的运行平台是Eclipse+CDT+MingW.

65,189

社区成员

发帖
与我相关
我的任务
社区描述
C++ 语言相关问题讨论,技术干货分享,前沿动态等
c++ 技术论坛(原bbs)
社区管理员
  • C++ 语言社区
  • encoderlee
  • paschen
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
  1. 请不要发布与C++技术无关的贴子
  2. 请不要发布与技术无关的招聘、广告的帖子
  3. 请尽可能的描述清楚你的问题,如果涉及到代码请尽可能的格式化一下

试试用AI创作助手写篇文章吧