H
Hicham Mouline
Hello,
This compiles
#include <iostream>
class Base {
public:
typedef double type;
};
class Derived : public Base {
public:
void f(type t) const {}
};
While this
template <typename T>
class Base {
public:
typedef double type;
};
template <typename T>
class Derived : public Base<T> {
public:
void f(type t) const {} // type has not been declared
};
This templated version requires
template <typename T>
class Derived : public Base<T> {
public:
void f(typename Base<T>::type t) const {}
};
Is g++3.4 standard compliant here? Or is this a g++3.4 restriction?
writing
typename Base<T>::type
is tedious?
I tried to put type in a non template base class B of Base, but in Derived,
I still needed to qualify B::type
rds,
This compiles
#include <iostream>
class Base {
public:
typedef double type;
};
class Derived : public Base {
public:
void f(type t) const {}
};
While this
template <typename T>
class Base {
public:
typedef double type;
};
template <typename T>
class Derived : public Base<T> {
public:
void f(type t) const {} // type has not been declared
};
This templated version requires
template <typename T>
class Derived : public Base<T> {
public:
void f(typename Base<T>::type t) const {}
};
Is g++3.4 standard compliant here? Or is this a g++3.4 restriction?
writing
typename Base<T>::type
is tedious?
I tried to put type in a non template base class B of Base, but in Derived,
I still needed to qualify B::type
rds,