1.文件yoffgroup.h
class YOffGroup
{ public: YOffGroup(short roomId); ~YOffGroup(); inline bool setOffGamerWithSeat(char seat, YGamer*gamer);private: YGamer *m_offGamers[3]; /**< 存放替代玩家游戏的AI, 下标就是座位号*/ short m_roomId; /**< 该组所对应的房间id */};2.源文件 yoffgroup.cpp
bool YOffGroup::setOffGamerWithSeat(char seat, YGamer *gamer){
if(seat<0|| seat >2) { return false; } YGamer *old = m_offGamers[seat]; // delete m_offGamers[seat]; delete old; m_offGamers[seat] = gamer; return true;} 3,以上将标注的有inline的函数的实现放在了源文件,在调用时就会出这样的莫名错误error: undefined reference to `YOffGroup::setOffGamerWithSeat(char, YGamer*)'
4,对于以上的错误有两个解决方案
a,将inline去掉
b,将原文件中对应的实现放到头文件中