-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexam 05.cpp
More file actions
53 lines (38 loc) · 974 Bytes
/
exam 05.cpp
File metadata and controls
53 lines (38 loc) · 974 Bytes
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
//Create a class name tree which has two fields, width and height. Create a constructor
// and destructor. Make a set function to take input from the user.
//Make a display function to show value. Create an object which has a parameter.
#include <iostream>
using namespace std;
class tree
{
public:
float height,width;
tree (float a, float b)
{
width = a;
height = b;
cout<<"Tree set width is :"<<width<<endl<<"Tree set height is :"<<height<<endl;;
}
~tree()
{
cout<<"Destructor is called";
}
void setvalue()
{
float a,b;
cout << "Enter tree Width and Height :";
cin >>a>>b;
width = a;
height =b;
}
void displayvalue()
{
cout <<"Tree width is :"<<width<<endl<<"Tree height is "<<height<<endl;
}
};
int main ()
{
tree ob1(89.99,88.09);
ob1.setvalue();
ob1.displayvalue();
}