question about structure of a node
Can someone help me out?
I am a little bit confused of what to do here.
If a simple structure of a code looks like this
1 2 3 4 5 6
|
struct node{
int data;
struct node *left;
struct node *right;
};
|
How would i construct a node if the data is complicated. Like , it is a structure and should compose of name, ID number, and so on?
thank you for reading :) hoping for answers :D
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
|
struct complicated_data{
std::string name;
int ID;
};
struct node_of_complicated_data{
complicated_data data;
node_of_complicated_data *left, *right;
};
//Or
template<class T>
struct node{
typedef T value_type;
value_type data;
node *left, *right;
};
node<complicated_data> asdf; //instantiation
|
Thank you very much :D
Topic archived. No new replies allowed.