Calling a parameterless constructor from a parametered one

Fred Labrosse ffl@aber.ac.uk
Mon Apr 18 11:23:00 GMT 2005


On Monday 18 Apr 2005 11:59, Grigory Zagorodnev wrote:
> Fred Labrosse wrote:
> >    baseClass(T val)
> >
> >       : theVal(val)
>
> ...
>
> > //    baseClass(T val)
> > //       : baseClass()
>
> You've got two constructors with identical arguments list so them failed
> to overload.
>
>

Sorry, should have been clearer.  I meant commenting out the first 
parameterised constructor and replacing it with the second (which in effect 
in that case does the same thing).  If I do that, I get:

g++ test.cpp
test.cpp: In constructor `baseClass<T, defaultVal>::baseClass(T) [with T = 
int,T defaultVal = 5]':
test.cpp:41:   instantiated from here
test.cpp:18: error: type `class baseClass<int, 5>' is not a direct base of 
`baseClass<int, 5>'

Cheers,

Fred



More information about the Gcc-help mailing list