This is my header file for my Stack class...
Code:
// Stack.h
#ifndef STACK_H
#define STACK_H
#include "Utility.h"
const int MAXSTACK = 10;
struct Stack_entry
{ char element;
bool flag;
};
class Stack {
public:
Stack();
bool empty() const;
Error_code pop();
Error_code top(Stack_entry &item) const;
Error_code push(const Stack_entry &item);
private:
int count;
Stack_entry entry[MAXSTACK];
};
#endif
How can I access
Code:
struct Stack_entry
{ char element;
bool flag;
};
from main once I've initialized a stack from this class?
[edit] - Nevermind figured it out...
Solution for any interested:
I declared a variable of type Struct_entry in my main like so:
then used my top function to put the top of my stack into x:
then accessed it normally like:
Code:
x.flag
or
x.element
Just remember to pop off the old value on the stack and push the new value once you're done with it