i am little bit connfused with template inheritance can any one suggest me the solution plss

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

#include <iostream>

using namespace std;

template<class T>
class class0 {

protected:
   static const int p =300;
public:
    char getChar();
};

template<class T>
class class1:public class0<T> {
public:
    void printChar();
};
template<class T>
void class1<T>::printChar(){
    cout<< p<<endl;//p was not declared in this scope
}

int main()
{
    cout << "Hello world!" << endl;
    return 0;
    
}


C:\Users\NARENDRA\Desktop\pointers lab\template inheritance\main.cpp||In member function 'void class1<T>::printChar()':|
C:\Users\NARENDRA\Desktop\pointers lab\template inheritance\main.cpp|21|error: 'p' was not declared in this scope|
||=== Build finished: 1 errors, 0 warnings ===|

Last edited on
closed account (zb0S216C)
Qualify p with class0. For example: class0<T>::p;

Wazzak
Last edited on
Topic archived. No new replies allowed.