#include <iostream>
template<typename T>
class A
{
public:
A() {std::cout << "constructor A\n";}
~A() {std::cout << "destructor A\n";}
T Apublic;
protected:
T Aprotected;
private:
T Aprivate;
};
template<typename T>
class B : public A<T>
{
public:
B() {std::cout << "constructor B\n";}
~B() {std::cout << "destructor B\n";}
void init() {Apublic = 0; Aprotected = 1;}
T pub() {return Apublic;}
T pro() {return Aprotected;}
};
int main()
{
B<double> a;
a.init();
std::cout << a.pub() << a.pro() << "end!\n";
return 0;
}
The error massage says
: In member function 'void B<T>::init()':
:22: error: 'Apublic' was not declared in this scope
:22: error: 'Aprotected' was not declared in this scope
: In member function 'T B<T>::pub()':
:23: error: 'Apublic' was not declared in this scope
: In member function 'T B<T>::pro()':
:24: error: 'Aprotected' was not declared in this scope