Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/cplusplus/135.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ 错误:在';之后应为限定名称;typename';C++;_C++ - Fatal编程技术网

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();}
};