Hi,
I was reading some text about the implementation of Stack using using our own class. The definition for this is placed in Stack.h file and code in Stack.cpp file. Here's my Stack.h file
typedef char Stack_entry;
const int maxstack=10;
class Stack
{
public:
Stack();
Error_code push(const Stack_entry &item);
Error_code pop();
Error_code top(Stack_entry &item)const;
bool empty()const;
private:
int count;
Stack_entry entry[maxstack];
};
In one of my methods in Stack.cpp, I write
Error_code Stack::push(const Stack_entry &item)
{
Error_code outcome=sucess;
if(count>=maxstack)
{
outcome=overflow;
}
else
{
entry[count++]= item;
}
return outcome;
}
I am confused if this Error_code was being used in general context by the author?
If not, how do we mention the type for Error_code?
Error_code has a variable named outcome which is initially set to success. When this is returned actually, what's being returned?
For eg: When we return, we know we are returning a number, char returns an alphabet but what is this type Error_code?
I have declared three methods as Error_code in Stack.h as
Error_code push(const Stack_entry &item);
Error_code pop();
Error_code top(Stack_entry &item)const;
While compiling my own Stack class, I am getting the error that Error_code does not name a type. :-|