2012-03-12 103 views
0

我正在用C++编程一个简单的“房子出价”应用程序。我编译并得到这个错误消息:无法解析的外部符号错误是什么意思?

1>Hus.obj : error LNK2019: unresolved external symbol "public: __thiscall 
Bud::Bud(void)" ([email protected]@[email protected]) referenced in function "public: __thiscall 
Hus::Hus(int,class Person,class std::basic_string<char,struct 
std::char_traits<char>,class std::allocator<char> >)" 
([email protected]@[email protected]@@[email protected][email protected]@[email protected]@[email protected]@[email protected]@[email protected]@@Z) 
1>F:\c++\prosjekter\Øving 4\Ov4Oppg1\Debug\Ov4Oppg1.exe : fatal error LNK1120: 1 
unresolved externals 

任何人都有线索?

+0

我猜你没有与在Hus.obj需要Bud.obj联......? – 2012-03-12 18:36:23

回答

2

你得到的错误,因为你还没有实现

Bud::Bud() 

你从Hus::Hus()调用。

你最有可能是这样的:

class Bud 
{ 
public: 
    Bud(); 
} 

忘落实构造。您需要添加

Bud::Bud() 
{ 
    //whatever 
} 

到一个执行文件,编译并链接到生成的obj文件。

+0

是的,我其实是。非常感谢m8 :-) – user1264836 2012-03-12 18:50:40

+0

@ user1264836你究竟做了什么? – 2012-03-12 18:54:03

+0

我有一个我使用的构造函数,它不像默认的构造函数。但是我在头文件中声明了一个空的构造函数,因为声明了一个Bud表。所以我忘记了这个空的构造函数在.cpp文件中的实现。 – user1264836 2012-03-12 19:02:14

1

我有一个简单的错误导致同样的错误:我忘了在cpp文件中实现我的一个函数。 当其他类的对象调用了这个类的一个我忘记实现的对象时,就会出现这个错误。 我认为这个错误看起来像一个“链接错误”,因为我的函数返回在我的项目的其他文件中定义的类型。

Noobie错误...但它可以成为有用的人......

相关问题