以下代码给出了错误"unable to match function definition to an existing declaration"
。我的语法是否正确?
CharPlayer.h
class CharacterPlayer
{
public:
template <class cType>
cType createCharacter(cType characterType);
};
CharPlayer.cpp
template <class cType>
cType CharacterPlayer::createCharacter(cType characterType)
{
return 3;
}
主要
CharacterPlayer *controllerPntr = new CharacterPlayer;
controllerPntr->createCharacter(1);