2014-03-26 277 views
1

我开始用C++编程和IM得到一个错误,我不能化解或理解错误C2600:这是什么意思?

错误C2600:“kingMobile :: KingChatFilter :: KingChatFilter”:无法定义一个编译器生成的特殊成员函数(必须声明类第一)

这里是代码:

#include "buraco/game/board/model/KingChatFilter.h" 
#include "buraco\game/board/model\GamePlayController.h" 
#include "boost/lexical_cast.hpp" 
#include "s3e.h" 
#include "buraco\Player.h" 
namespace kingMobile { 

    KingChatFilter::KingChatFilter() { 
     //this->gamePlayController = gamePlayController; 

    } 

    string KingChatFilter::filter(string msg){ 

     if(msg == "anus"){ 
      return "amigao"; 
     } 
     return msg; 
    } 
} 

这里我有我的.h文件

#include "buraco\game/board/model\CardGroup.h" 
#include "boost/function.hpp" 
#include "oxygine-framework.h" 

namespace kingMobile { 

    class KingChatFilter : public boost::enable_shared_from_this<KingChatFilter> { 
     public: 

      string filter(string msg); 

     private: 

    }; 

    typedef boost::shared_ptr<KingChatFilter> spKingChatFilter; 
} 
+6

你没有声明构造函数。 – chris

+0

(在KingChatFilter.h中的类定义中) –

+0

有我的KingChatFilter.h ...我没有声明那里吗? – user3120770

回答

5

错误mesage意味着此构造(特殊成员函数)

KingChatFilter() 

在第一必须在类定义进行声明。例如,

class KingChatFilter 
{ 
public: 
    KingChatFilter(); 
//... 
}; 

只有在那之后,您才可以在类定义之外定义它。

您不能重新定义包含默认构造函数的编译器构造函数隐式声明的内容。

其实我反复的编译器错误消息::)

/您/不能定义一个编译器生成的特殊成员函数(必须 在班里第一个声明)

2

即使您已经在代码中定义了构造函数的实现,仍然需要在该类的定义中声明该函数。 在这种情况下,您需要添加KingChatFilter();在你班级的公共部分(在.h中)