Write your question here This is my program that convert an inflix expression to an postfix and prefix form and it run okay but im having trouble how to put a menu option like this
A]Prefixform
B]Postfixform
c]enter another expressio
d]exit
typedef struct stack
{
int data[MAX];
int top;
}stack;
int precedence(char);
void init (stack *);
int empty (stack *);
int full (stack *);
int pop (stack *);
void push (stack *, int);
int top (stack *);
void infix_to_prefix (char infix[], char prefix[]);
void infix_to_postfix (char infix[], char postfix[]);
void eval_prefix (char prefix[]);
void eval_postfix (char postfix[]);
int evaluate (char x, int op1, int op2);
I tried to write a more flexible menu and stumbled in virtuality problems, maybe someone can lend me a hand or something in that way to find the way out...
First I created for each task a class which are derived from a base class.
Then I stored all the instances into a map.
When I call "MenuBase::exec();" : always the exec of the base class is called!
I tried to fix the problem with defining the exec of the base class as pure virtual ( = 0;) but then I can not store the instances into the map.
ok, now I can answer your first question :
Since the instances are within the scopes they are not dangled!
The objects are freed when the application is finished.
edit:
second: let us ask the founder of this thread bubbles102289, if my solution is for the wastebasket. If he/she says "thumbs down" I'll delete all my contributions in this thread.