Problem with derived templates
andre maute
andre.maute@gmx.de
Tue Mar 23 21:04:00 GMT 2010
Hi Axel,
first read
http://gcc.gnu.org/gcc-3.4/changes.html (C++ section)
http://gcc.gnu.org/develop.html#timeline
which indicates that gcc implements this rule since Apr 18 2004
then see my suggestion below
> I have a problem with a derived template class. It seams that all the
> members of the base class are not visible in the derived class. If I then
> make an instance of the derived class, I can access all members of the
> derived and the base class ??
>
> I'm using the CodeSourcery gcc4.4.1 (tried also 4.3.3, 4.3.2) to compile
> the following.
>
> Im sorry, my english is not very good, so please have a look at the
> sourecode:
>
>
> template <int N> class TBase {
> public:
> int Array[N];
> int fb1() { return Array[0]; };
> }; // everything is OK in TBase
>
> template <int NN> class TDerived : public TBase<NN> {
> int UU;
> public:
> int fc2() { return Array[0]; }; // error: 'Array' was not declared
> in this scope int fc3() { return UU; }; // OK
> int fc4() { return fb1(); }; // error: .... 'fb1' must be
> available };
prefix the ones from TBase with this
this->Array[0];
this->fb1();
Regards
Andre
More information about the Gcc-help
mailing list