R
richard
Sorry if this is an obvious question, but I try to let a template class
inherit another template class.
The code here under is a simplification of how I try to do that, but
the compiler complains that 'c' in line '30 ' wasn't declared.
" (g++)
test.h: In member function ‘T Test2<T>::give()’:
test.h:30: error: ‘c’ was not declared in this scope
"
I have absolute no idea what the problem and/or solution is, can anybody
help me with that please?
Thank you,
Driehoek
////////////////////////////////////////
4: template <class T>
5: class Test
6: {
7: public:
8: virtual void
9: set (T i)
10: {
11: c = i;
12:
13: }
14: virtual T
15: give ()
16: {
17: return c;
18: }
19: protected:
20: T c;
21: };
22:
23: template <class T>
24: class Test2 : public Test<T>
25: {
26: public:
27: T
28: give ()
29: {
30: return c * 2;
31: }
32: };
////////////////////////////////////////
inherit another template class.
The code here under is a simplification of how I try to do that, but
the compiler complains that 'c' in line '30 ' wasn't declared.
" (g++)
test.h: In member function ‘T Test2<T>::give()’:
test.h:30: error: ‘c’ was not declared in this scope
"
I have absolute no idea what the problem and/or solution is, can anybody
help me with that please?
Thank you,
Driehoek
////////////////////////////////////////
4: template <class T>
5: class Test
6: {
7: public:
8: virtual void
9: set (T i)
10: {
11: c = i;
12:
13: }
14: virtual T
15: give ()
16: {
17: return c;
18: }
19: protected:
20: T c;
21: };
22:
23: template <class T>
24: class Test2 : public Test<T>
25: {
26: public:
27: T
28: give ()
29: {
30: return c * 2;
31: }
32: };
////////////////////////////////////////