尝试将模板成员函数拆分为header和cpp文件

时间:2015-02-21 20:53:20

标签: c++ templates

以下代码给出了错误"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);

0 个答案:

没有答案
相关问题