l.s.rockfan@web.de
11/15/2008 10:06:00 AM
Salt_Peter wrote:
> On Nov 14, 3:30 pm, "l.s.rock...@web.de" <l.s.rock...@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
>>
>> /* further member functions */
>>
>> }
>>
>> The compiler always tries to identify A as a member variable not being
>> found, instead of the base class' constructor.
>
> The following is a class:
>
> class A { };
>
> this is not:
>
> class A { }
>
> The following declares a class and defines a constructor:
>
> class A
> {
> A() { }
> };
>
> or
>
> // A.hpp (missing include guards)
> class A
> {
> A(); // declaration only
> };
>
> // A.cpp
> A::A() { } // definition
>
> Basically, a semicolon denotes a declaration.
That's not the point. I just forgot the semicolons in the example.
I found out, that my problem is not only specific to explicit
constructor calls, but occurs everytime I want to call a polymorph
member function of the base class (which is a template class).
I get an undefined reference error from ld.
That's why I start a new post for the more general problem description.