-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathbinarytree.cpp
53 lines (51 loc) · 947 Bytes
/
binarytree.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#include<iostream>
using namespace std;
class human
{
public:
string name;
int age;
string sex;
string DOB;
human *left; //left child
human *right; //right child
human()
{
name="Maya Rani Khare";
age=76;
sex="Female";
DOB="18/11/1941";
}
void insert()
{
cout<<"Enter the name of the person"<<endl;
getline(cin,name);
cout<<"Enter the age of the person"<<endl;
cin>>age;
cout<<"Enter the sex of the person"<<endl;
cin>>sex;
cout<<"Enter the DOB of the person"<<endl;
cin>>DOB;
}
void show()
{
cout<<"Name of the person is "<<name<<endl;
cout<<"Age of the person is "<<age<<endl;
cout<<"Sex of the person is "<<sex<<endl;
cout<<"DOB of the person is "<<DOB<<endl;
}
};
int main()
{
human *node,*ptr,*root;
cout<<"Program for Binary Trees"<<endl;
cout<<"Lets enter the root node"<<endl;
node=new human;
node->insert();
node->left=NULL;
node->right=NULL;
root=node;
cout<<"Lets see the root details of the Family"<<endl;
node->show();
return 0;
}