Tree Creation
Tree Creation
#include <string.h>
string label;
//char label[10];
int ch_count;
} * root;
public:
void create_tree();
GT()
root = NULL;
};
void GT::create_tree()
cin.get();
getline(cin, root->label);
cout << "Enter number of chapters in book : ";
root->ch_count = tchapters;
cout << "Enter the name of Chapter " << i + 1 << " : ";
cin.get();
getline(cin, root->child[i]->label);
cout << "Enter number of sections in Chapter : " << root->child[i]->label << " : ";
cout << "Enter Name of Section " << j + 1 << " : ";
cin.get();
getline(cin, root->child[i]->child[j]->label);
int i, j, k, tchapters;
if (r1 != NULL)
tchapters = r1->ch_count;
{
cout << "\nChapter " << i + 1;
int main()
int choice;
GT gt;
while (1)
switch (choice)
case 1:
gt.create_tree();
case 2:
gt.display(root);
break;
case 3:
exit(1);
default:
return 0;