I am writeing a very drifficult mathmatical program and I extremlly
need to make a tree of opraters.
I've made a structure like this:
struct tree_struct{
struct tree_struct *left;
char node;
struct tree_struct *right;
};
I need to make an array of this new type,and use it as a stack.so
I did so:
struct tree_struct *stack[4];
and by using 'new'(or malloc in c) I got memory for this pointer.
my problem is in this assignment :
tree-%26gt;left= stack[1];
why this assignment is not true ?I don't know?!!
please help me.
thanks for spending your time to answer my question.
C++ programmers please answer this question?
You have an allocation problem...
is you stack[1] previously allocated like: stack[1]=new struct tree_struct;?
if so than tree-%26gt;left=stack[1] should be valid (but be carefull to previous allocate the "tree" var...).if tree is NULL the tree-%26gt;left is ilegal...
Reply:I have a few questions to ask before i can answer ur question:
1) How exactly are u allocating the nodes of the tree.. plz show me the intended statement
2) Is the array storing the mem of the new nodes?
3) if u intend to do tree_struct-%26gt;left=stack[1] u atleast need to use a handle to access the member... i really dont understand what u're doing there. Perhaps a completed code segment would help.
Reply:wat is your exact problem ???
i cant get you ...
the stack starts with 0 or 1 ????????????
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment