l.s.rockfan@web.de
11/14/2008 10:01:00 PM
Obnoxious User wrote:
> On Fri, 14 Nov 2008 21:28:53 +0100, l.s.rockfan@web.de wrote:
>
>> Hello,
>>
>> how do i have to call an inherited, templated class constructor from the
>> initializer list of the inheriting, non-templated class constructor?
>>
>> example code:
>>
>>
>> template<typename T>
>> class A
>> {
>> protected:
>> sometype* something;
>> T something_else; /*gives the template some sense here*/
>> public:
>> A(sometype* param) : something(param) {};
>> }
>>
>>
>> class B : public A<int>
>> {
>> public:
>> B(sometype* param) : A(param) {}; // <== Compiler Error
>>
>
> B(sometype * param) : A<int>(param) {}
>
Thanks.
Mysterious, it really works.
All the time I tried it before, I coded it outside the class body like
B::B(sometype* param) : A<int>(param) {}
and it didn't work because of an ld error.
When I move it inside the class body (like in my example code above) it
works.
Could someone explain this behaviour to me, please?