Hi,
I want to pass tree as an argument to other function in C. I am able to pass the tree comfortably,but how do I access the children of the tree in the called function???

TIA
Best Regards
Vishal Agarwal

Recommended Answers

All 5 Replies

Welcome to the forum Vishal, Your question is very faint for us, without knowing your actual implementation. Please post example codes so we can have an idea about what exactly your problem is.

Thanks a lot for such a quick reply.
I cannot post the code..I am very sorry for this.
BUt to be more precise, I am creating a tree say T in a function say F1. After that another function say f2 is called from f1 with the tree T as one of the argument. Upto this it is fine.
Now I want to access the nodes of T from f2. How do I do that??

Did I make myself clear???Sorry for my english.

Best regards
Vishal Agarwal

Are you sending a copy of the object or a reference.
Or is it through a pointer .

class Tree{
//values
};

void f1()
{
  Tree x;
 //put values into x
 f2(x);
}

void f2(Tree& temp)
{
//DO something with tree(temp)
}

Exactly. You got me...

Wouldnt you do it normally as In ........ temp.node=value; By that the value of x in f1 will change.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.