Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
why we have declared these two TreeNode pointers left
#1
Sir, 1)My question is why we have declared these two TreeNode pointers left , right within the same TreeNode class, can we use other pointers like integer or etc? 2)If we have declared TreeNode pointers within the same class then these pointers also holds the value like Object , left and right? All I am asking cause behind doing this I have a sort of confusion with this, plz explain briefly.... Class TreeNode { private: Object * object; TreeNode * left; TreeNode * right; 62. }; // end class TreeNode };
Reply
#2
1. As the data type of left and right pointer is same as the parent class TreeNode. Therefore we declare left and right pointer with TreeNode data type. Therefore we can not use any other type of data like integer, float, char etc.
2. Object is a private data element of Object *, used to store the tree element (value) inside the node of the tree. Left is a private data member of type TreeNode*, it is used to store a pointer to the left sub-tree. Right is a private data member of type TreeNode *, employed to store a pointer to the right sub-tree.

0300-9520262
Get solution in 24 hour
|cpmputer & internetConfusedmileys81:[SIZE="4"][SIZE="3"]....[/SIZE][/SIZE]
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Dangling Pointers Explain in C++ Vuhelper 0 7,270 05-31-2012, 01:52 AM
Last Post: Vuhelper
  what is the difference between 1. Double Right-Left Rotation 2. Double Left-Right Rot Vuhelper 0 2,020 01-04-2012, 10:37 PM
Last Post: Vuhelper
  reenode* node = new treenode(info); Vuhelper 0 1,795 01-04-2012, 10:18 PM
Last Post: Vuhelper
  why we use pointers or reference except using real name of var. what is buffer point saneha 1 9,881 05-02-2011, 06:24 PM
Last Post: Vuhelper
  why we use pointers or reference except using real name of var. what is buffer point saneha 1 5,227 05-02-2011, 06:05 PM
Last Post: Vuhelper
  Pointers are not accessible for static member funcion saneha 1 2,299 05-02-2011, 05:48 PM
Last Post: Vuhelper
  static member function can be declared explicitly? saneha 1 4,967 05-02-2011, 06:56 AM
Last Post: Vuhelper
  Pointers in c++ 2011 saneha 1 2,839 05-02-2011, 06:30 AM
Last Post: Vuhelper
  Linux Unix Windows Mac OS If a function has not been declared before its definition, sana.pari 0 3,557 04-24-2011, 05:56 PM
Last Post: sana.pari
  declared one varibale char s1[10] but when i am inputing the string sana.pari 1 1,136 04-24-2011, 02:11 AM
Last Post: Xpert

Forum Jump:


Users browsing this thread: 1 Guest(s)