I am new to C++. During my learning phase I encountered with below issue.
I am trying to derive a class stack
from a class template Queue
.
Compiler throws below error in constructor of stack
..\src\TrainingDay2.cpp:44:3: error: 'b' was not declared in this scope
b=a;
Please help to find out the root cause.
#include <iostream>
using std::cout;
using std::endl;
template<class T> class Queue //Base class
{
private:
T ArrQueue[20];
protected:
T* a;
T* b;
public:
Queue() { cout<<"QUEUE CONST "<< endl; }
void push(T x);
void pop(void);
};
template <class T>
class stack :public Queue<T> // Derived class
{
public:
stack():Queue<T>() {
b=a;
}
void pop() {
b--;
}
};
int main()
{
stack<int> S;
return 0;
}