template definition of non-template
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?
精彩评论