C++ 错误:在';之后应为限定名称;typename';C++;
请在下面找到我的代码。如果有人能指出我的愚蠢,我将不胜感激。谢谢C++ 错误:在';之后应为限定名称;typename';C++;,c++,C++,请在下面找到我的代码。如果有人能指出我的愚蠢,我将不胜感激。谢谢 class LapIplImage{ private: IplImage *m_img; public: //////////////////////////////////////////////// // construct LapIplImage():m_img(NULL){} LapIplImage <typename type>(int width, int he
class LapIplImage{
private:
IplImage *m_img;
public:
////////////////////////////////////////////////
// construct
LapIplImage():m_img(NULL){}
LapIplImage <typename type>(int width, int height):m_img(0){ Create(width, height); }
~LapIplImage(){ Release(); }
//Expected a qualified name after 'typename'
class-LapIplImage{
私人:
IplImage*m_img;
公众:
////////////////////////////////////////////////
//构造
LapIplImage():m_img(NULL){}
LapIplImage(int-width,int-height):m_-img(0){Create(width,height);}
~LapIplImage(){Release();}
//“typename”后应为限定名
不能使用用作标识符的名称
所以您可以尝试一些系统未使用的单词
像typ或TypE。您忘记了“模板”这个词:一,
class-LapIplImage{
私人:
IplImage*m_img;
公众:
////////////////////////////////////////////////
//构造
LapIplImage():m_img(nullptr){}
模板LapIplImage(int-width,int-height):m_-img(0){Create(width,height);}
~LapIplImage(){Release();}
};
这不应该像这个LapIplImage(int-width,int-height):m_-img(0){Create(width,height)}~LapIplImage(){Release();}你在哪里使用类型?改变,也不使用它,所以我不明白为什么你需要模板在这里<代码>类型<代码>是C++中的有效标识符,不是关键字。谢谢你告诉我。我很感激。这帮助我找到一个打印错误,注意“TEMPARTE”!
class LapIplImage{
private:
IplImage* m_img;
public:
////////////////////////////////////////////////
// construct
LapIplImage():m_img(nullptr){}
template <typename type> LapIplImage (int width, int height):m_img(0){ Create(width, height); }
~LapIplImage(){ Release();}
};