我正在尝试调用公共成员函数:
// main.cpp
#include "AH.h"
int somefunc()
{
//...
// it - object of class A
it.set_mean(angle, mean);
//...
}
在.h 中声明的
// AH.h
class A
{
//...
public:
inline void set_mean(const int angle, const double mean_value);
//...
}
并在.cpp文件中定义:
// A.cpp
#include "AH.h"
inline void A::set_mean(const int angle, const double mean_value)
{
mean[angle] = mean_value;
}
并收到LNK错误:
error LNK2019: unresolved external symbol "public: void __cdecl A::set_mean(int,double)" (?set_mean@A@@QEAAXHN@Z) referenced in function "int __cdecl somefunc(class std::vector<class A,class std::allocator<class A> > &)" (?somefunc@@YAHAEAV?$vector@VA@@V?$allocator@VA@@@std@@@std@@@Z)
为什么会这样?