更新时间:2023-11-29 13:59:58
这个错误通常意味着某些函数有声明,而不是定义。
This error often means that some function has a declaration, but not a definition.
示例:
// A.hpp
class A
{
public:
void myFunc(); // Function declaration
};
// A.cpp
// Function definition
void A::myFunc()
{
// do stuff
}
在您的情况下,找不到定义。问题可能是您正在包括一个头文件,这会带来一些函数声明,但你:
In your case, the definition cannot be found. The issue could be that you are including a header file, which brings in some function declarations, but you either:
一个常见的错误是你将一个函数定义为一个独立的类并忽略类选择器,例如
A common mistake is that you define a function as a standalone and forget the class selector, e.g. A::
, in your .cpp file:
错误: void myFunc(){/ * do stuff * /}
正确: > void A :: myFunc(){/ * do stuff * /}
Wrong: void myFunc() { /* do stuff */ }
Right: void A::myFunc() { /* do stuff */ }