Re: What does Ctor::Ctor prototype mean?
persres wrote:
For a class ABC. Can we declare the Ctor as ABC::ABC()?
class Base
{
public:
Base::Base() {}
virtual ~Base() {}
} ;
Everything in class Base is implicitly "in Base::", so there is no need to
qualify this constructor with Base::. Also, IIRC, this code is simply
ill-formed according to the C++ standard. I know that MSVC ignores that
though.
template <class T>
class ABC : public Base
{
public:
ABC::ABC() {} // Line 16 error
~ABC() {}
};
[...]
main.cpp(16) : error C3254: 'ABC<T>' : class contains explicit
override '{ctor}' but does not derive from an interface that contains
the function declaration
main.cpp(18) : see reference to class template instantiation 'ABC<T>'
being compiled
main.cpp(16) : error C3244: 'ABC<T>::ABC(void)' : this method was
introduced by '<Unknown>' not by 'Base'
What do these errors mean?
In short, it seems that the compiler complains that "ABC" is not a class. To
some extent, the compiler is right, because ABC is not a class but a class
template. As such, it rejects the "ABC::" qualification, I guess you could
qualify it with "ABC<T>::".
Note that it doesn't do so always, generally you can use ABC in a template
class name and it implicitly becomes ABC<T>, like e.g. with the constructor
and destructor.
Remove the useless qualifications and you should be fine.
Uli
--
Sator Laser GmbH
Gesch??ftsf??hrer: Thorsten F??cking, Amtsgericht Hamburg HR B62 932
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]