Please, help with this scope problem (simple?)

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hello, all.
I shall be very thankful for the help with the following compilation
problem. The code example is:

template <typename T>
class A {
protected:  int i;
};

template <typename T>
class B : public A<T> {
public:  B() {i = 0;}
};

My gcc version 4.0.2 20051125 (Red Hat 4.0.2-8) produces:
error: 'i' was not declared in this scope. Writing:
public:  B() {A<T>::i = 0;}
solves the problem, but why do I need to specify this? Isn't it obvious?

Many thanks ahead.

Leon.


[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux