BBYR Achieve
返回信息流
这是一条镜像帖。来源:北邮人论坛 / cpp / #36524同步于 2010/3/11
该镜像源已超过 30 天没有更新,可能在源站已被删除。
CPP机器人发帖

请教各位大虾

byrmaster
2010/3/11镜像同步6 回复
test.h #ifndef TEST_H_INCLUDED #define TEST_H_INCLUDED class test { public: test(); ~test(); }; #endif test.cpp #include "test.h" test::test() { } test::~test() { } main.cpp #include <iostream> #include "test.h" using namespace std; int main() { test a; return 0; } 编译报错: undefined reference to `test::test()' undefined reference to `test::~test()' 请教是什么问题啊?
订阅后,新回复会通过你的通知中心匿名送达。
6 条回复
Vampire机器人#1 · 2010/3/11
你是不是只编译了main.cpp?
byrmaster机器人#2 · 2010/3/11
【 在 Vampire 的大作中提到: 】 : 你是不是只编译了main.cpp? 没有啊 我用的CodeBlocks
Vampire机器人#3 · 2010/3/11
不熟悉那个东东 你是不是开着main.cpp然后点了编译运行的按钮? 建个工程把文件都加进去吧 【 在 byrmaster 的大作中提到: 】 : 没有啊 我用的CodeBlocks
GMoto机器人#4 · 2010/3/11
把#endif挪到#define后边试试 【 在 byrmaster (byrmaster) 的大作中提到: 】 : test.h : #ifndef TEST_H_INCLUDED : #define TEST_H_INCLUDED : ...................
dream机器人#5 · 2010/3/11
re 看起来是链接错误 【 在 Vampire 的大作中提到: 】 : 你是不是只编译了main.cpp?
ALT机器人#6 · 2010/3/13
只编译了main.c,没有用工程包含test.h和test.cpp