Templates + member inheritance

Why can't an inherited member be accessed directly, if it's
inherited from a template struct?

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#include <iostream>
using namespace std;

template <typename T>
struct base
{
 base(const T& tref):
 mType(tref)
 {}

protected:
 T mType; // potentially bad construction style with protected
};

template <typename T>
struct child:
public base<T>
{
 child(const T& tref):
 base<T>(tref)
 {}

 void fx()
 {
  cout << "mType == " << base<T>::mType << "." << endl;
  //cout << "mType == " << mType << "." << endl; // ERROR!
 }
};

int main()
{
 child<int> c(3);
 c.fx();
}
Topic archived. No new replies allowed.