开发者

template definition of non-template

开发者 https://www.devze.com 2023-03-18 05:24 出处:网络
I\'m getting a \"template definition of non-template\" compile error while trying to implement something like this :

I'm getting a "template definition of non-template" compile error while trying to implement something like this :

class BaseFoo
{
    BaseFoo();
    ~BaseFoo();

    virtual void method();
};

template <class A>
class Foo : public BaseFoo
{
 Foo();
    ~Foo();

    virtual void开发者_StackOverflow中文版 method();
};

Is it possible to redefine a method in a template class if it was previously defined in its baseclass which is not a templated class ?


Apparently this is a bug that was finally fixed in gcc 4.2. See http://gcc.gnu.org/bugzilla/show_bug.cgi?id=27211 .


Yes, this sort of thing is perfectly legal. The code you provided compiles fine in gcc 4.2.1.

Is this the exact code you are getting the error for? What compiler are you using?

0

精彩评论

暂无评论...
验证码 换一张
取 消