-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathshape.cpp
90 lines (90 loc) · 1.11 KB
/
shape.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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
#include<iostream>
#include<cmath>
using namespace std;
class Base
{
protected :
int number;
private :
Base()
{
number=0;
}
void const getno()
{
cout<<"Enter the number :- ";
cin>>number;
}
void const putno()
{
cout<<number<<endl;
}
friend class Square;
friend class Cube;
friend int main();
};
class Square : private Base
{
private :
void sq()
{
number=pow(number,2);
}
friend class Cube;
friend int main();
};
class Cube : private Base
{
private :
void cu()
{
number = pow(number,3);
}
friend int main();
};
/*class Cube : private Square
{
private :
void cu()
{
sq();
number = pow(sqrt(number),3);
}
friend int main();
};*/
void printcho()
{
cout<<"Choices :-\n1) Square\n2)Cube\n3)Exit\nEnter Your Choice : ";
}
int main()
{
int ch;
do
{
printcho();
cin>>ch;
if(ch==1)
{
Square ob;
ob.getno();
ob.sq();
ob.putno();
}
else if (ch==2)
{
Cube ob;
ob.getno();
ob.cu();
ob.putno();
}
else if (ch==3)
{
cout<<"Thank You";
break;
}
else
{
cout<<"Enter a valid Output"<<endl;
}
}while(ch!=3);
}