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 */
};spa
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;
}it
3,以上将标注的有inline的函数的实现放在了源文件,在调用时就会出这样的莫名错误io
error: undefined reference to `YOffGroup::setOffGamerWithSeat(char, YGamer*)'class
4,对于以上的错误有两个解决方案error
a,将inline去掉文件
b,将原文件中对应的实现放到头文件中
解决方案