使用inline时链接出错
不录 2004-03-24 10:45:28 方法一:
//a.h
class a
{
public:
inline int getvalue() {return m_value;}
private:
int m_value;
}
方法二:
//a.h
class a
{
public:
int getvalue();
private:
int m_value;
}
//a.cpp
inline int a::getvalue()
{
return m_value;
}
在vc++中使用第一种方法时链接时不会出错,但用第二种方法时有的时候会出现以下链接错误,不知道是为什么
error LNK2001: unresolved external symbol "public: int __thiscall a::getvalue(void)" (?getvalue@a@@QAE_NXZ)
Release/SBD.exe : fatal error LNK1120: 1 unresolved externals