I might just be confused on what I'm being asked to do ( and yes this is for a class).
I have the program almost completed I just have one miss understanding on my part. I'm asked to right a IntStack class and then derive and IntStackWPeek class, i have all this written and working but there is one thing that I don't get, i was told to disable 2 of the member functions from the IntStack class in the intStackWPeek class
this being IntStack has to functions isFull and isEmpty that aren't supposed to be part of IntstackWPeek's interface. I thought if I made them protected that would work, but that makes then not partof the base class interface too. I can't seem to find a references in my book to doing this except for a page that says you can do a private Inheritance then add a using line for the functions I want in the derived class. that didn't work for me either.
Code:
class IntStack {
vector<int> stack;
int max;
public:
bool isFull();
bool isEmpty();
virtual void push(int);
virtual int pop();
IntStack() : max(10) {};
IntStack(int n) : max(n) {};
IntStack(const IntStack&);
~IntStack() {stack.clear();};
};
class IntStackWPeek : public IntStack {
int value;
public:
int peek() { return value; };
void push(int);
int pop();
IntStackWPeek() : IntStack() {};
IntStackWPeek(int n) : IntStack(n) {};
~IntStackWPeek() {};
IntStackWPeek(const IntStackWPeek&);
};
I don't know if you need to see any more of my code but here is the class declerations.