hola, no logro hacer compilar el siguiente codigo con g++:

template<typename T>
class Base
{
    T _t;

public:
    Base(T t) : _t(t) {}
};

template<typename T>
class Derived: public Base<T>
{
public:
    Derived(T t) : Base(t) {}
};

int main()
{
    Derived<int> d(1);
    return 0;
}


el error que me tira es:

template5.cpp: In constructor 'Derived<T>::Derived(T)':
template5.cpp:14: error: class 'Derived<T>' does not have any field named 'Base'
template5.cpp: In constructor 'Derived<T>::Derived(T) [with T = int]':
template5.cpp:19:   instantiated from here
template5.cpp:14: error: no matching function for call to 'Base<int>::Base()'
template5.cpp:7: note: candidates are: Base<T>::Base(T) [with T = int]
template5.cpp:3: note:                 Base<int>::Base(const Base<int>&)
make: *** [template5] Error 1

lo extra;o es que el ejemplo esta tomado casi igual de
http://www.oopweb.com/CPP/Documents/CPPAnnotations/Volume/cplusplus19.html

habra que poner typename por algun lado? :)

slds.
francisco.
_______________________________________________
Lista de correo Programacion.
[email protected]
http://listas.fi.uba.ar/mailman/listinfo/programacion

Responder a