forked from dharmanshu1921/porject
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdiwakar.cpp
68 lines (64 loc) · 1.37 KB
/
diwakar.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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
#include<bits/stdc++.h>
using namespace std;
class Human{
bool health;
public:
double height;
double weight;
int age;
char *name;
void sethealth(bool health)
{
this->health=health;
}
bool gethealth(){
return health;
}
// Human(int a,double b){
// cout<<"constructor called"<<endl;
// age=a;
// height=b;
// // cout<<age<<" "<<height<<endl;
// }
Human(){
name=new char[100];
}
// copy constructor
// Human(Human& temp){
// this->age=temp.age;
// this->height=temp.height;
// }
void setName(char name[]){
strcpy(this->name,name);
}
void setAge(int age){
this->age=age;
}
void setHeight(int height){
this->height=height;
}
void print(){
cout<<this->age<<" "<<this->height<<endl;
cout<<this->name<<endl;
}
};
int main(){
// Human ritik;
// ritik.health=false;
// ritik.height=5.11;
// ritik.weight=53;
// ritik.setage(21);
// cout<<ritik.getage();
Human *a=new Human();
char name[10]="Aniket";
name[0]='N';
a->setName(name);
a->setAge(21);
a->setHeight(5.11);
a->print();
Human i(*a);
name[0]='A';
i.setName(name);
i.print();
return 0;
}