!"" $%&'()*+ &'+,'%-.'%/(0 1234
5556789:;8<987=:>=86?;@:
A%B'C*. B(DE. +) FG%H. . +EI(FJ.
!"#$#%# &'() *+,-./+ 0# 1#0234$5/#64 .$ -.+ $+14-7,. 84 -.9:#;3+1# <==>?)@@AAA'=B=CDEFG?>CEH='ICJ@I>GB?>GB?@I>>KIGF??L?KCMNLI=?'<=J
O8,./,+74 -.$./+ .$ :1+941+74P $# 84 9.$+Q+R+1##7 ,# .,3#;, -.9:#;341.7' S.$./+74 84 $#$4,+ 0# 835%#; ,# ,4$.87:#,.87 ,# 8#;7.7P $# 84 1#T.7+ .Q3#;, ,# /4UT+'
(' V# 84 1#0234$# $#$4,+.7 :1+941 0# /.3594, ,# W -57++ W' V# 84 -.9:#;3+1# $+14-7,. ,# 8#;7.7P 8. XDY Z=P /. ,4:1.94,47 .T3+-' [' \87#7# 0#$#%#P .,3#;, $# 84 9.$+Q+R+1# ,# 7.; ,#%+, ]7. ^4 84 $.$#$4 T+T3+.74-#7# _FG`CDE=
"' S.$' &'('
#include
using namespace std; class Box { public:
3
!"" $%&'()*+ &'+,'%-.'%/(0 1234
double length; double breadth; double height;
5556789:;8<987=:>=86?;@:
// Length of a box // Breadth of a box // Height of a box
}; int main( ) { Box Box1; // Declare Box1 of type Box Box Box2; // Declare Box2 of type Box double volume = 0.0; // Store the volume of a box here // box 1 specification Box1.height = 5.0; Box1.length = 6.0; Box1.breadth = 7.0; // box 2 specification Box2.height = 10.0; Box2.length = 12.0; Box2.breadth = 13.0; // volume of box 1 volume = Box1.height * Box1.length * Box1.breadth; cout << "Volume of Box1 : " << volume <
1
!"" $%&'()*+ &'+,'%-.'%/(0 1234
5556789:;8<987=:>=86?;@:
. !"#$%$&$'() *"# 7.3. #include
#include using namespace std; class Box { public: double length; double breadth; double height; };
// Length of a box // Breadth of a box // Height of a box
int main( ) { Box Box1;
// Declare Box1 of type Box
Box Box2; // Declare Box2 of type Box double volume1 = 0.0; double volume2 = 0.0; // box 1 specification Box1.height = 5.0; Box1.length = 6.0; Box1.breadth = 7.0; // box 2 specification Box2.height = 10.0; Box2.length = 12.0; Box2.breadth = 13.0; // volume of box 1 volume1 = Box1.height * Box1.length * Box1.breadth; cout << "!"#$%&' '( )*+( ,$-./( : " << volume1 <
K
!"" $%&'()*+ &'+,'%-.'%/(0 1234
5556789:;8<987=:>=86?;@:
cout << "!"#$%&' '( +-"*( ,$-./( : " << volume2<
max(volume1,volume2); return 0;
.+,-'./-(017.1.3.
!' "#$#%#'&'W'
i147j.$,#7# 0#$#%#P 8:.14$T# ,# /.3594,+ ,# $/4 -57++P 9.$+Q+R+1#,# 8. -.1+87464 ,# M:;>N7OPN:7 + =CEH=LD -#-. +9:3+R+74, :.-#U5/#%P :1+$15U4, $. 8+74 %34,./+ ,# Q5,-R++74'
L
!"" $%&'()*+ &'+,'%-.'%/(0 1234
5556789:;8<987=:>=86?;@:
<==>?)@@AAA'=B=CDEFG?>CEH='ICJ@I>GB?>GB?@I>>K=CEH=LD'<=J
6 R+)64616 #include using namespace std; class Box { public:
// Constructor definition Box(double l = 2.0, double b = 2.0, double h = 2.0) { cout <<"Constructor called." << endl; length = l; breadth = b; height = h; } double Volume() { return length * breadth * height; }
intreturn compare(Box { Volume() > box.Volume(); this->box) } private: double length; double breadth; double height;
// Length of a box // Breadth of a box // Height of a box
}; int main(void) { Box Box1(3.3, 1.2, 1.5); Box Box2(8.5, 6.0, 2.0);
// Declare box1 // Declare box2
if(Box1.compare(Box2)) { cout << "Box2 is smaller than Box1" <
Q
!"" $%&'()*+ &'+,'%-.'%/(0 1234
5556789:;8<987=:>=86?;@:
$ ' k#1+;#,7+ 0# /4UT#) +87. -#-. /. :147j.$,#7# 0#$#%#P $# 84 :1.T#
0# 1#0,+ /14$,.87+ + Q.19+P 8. 9.$+Q+-#R+;# ,# -.$.7' !' "#$#%#'&'[' l#834$5/#64 @ ZH?)@@AAA'=B=CDEFG?>CEH='ICJ@I>GB?>GB?@I>>KEH
"' mC$'&'[' 9.$+Q+-#R+;#P 0# 8:.14$T# ,# $/4 :./1]+,+' #include using namespace std; // Base class
class Shape { public: void setWidth(int w) { width = w; } void setHeight(int h) { }
height = h;
protected: int width; int height; }; // Derived class class Rectangle: public Shape { public: int getArea() { return (width * height); } }; intRectangle main(void) { Rect1; Rectangle Rect2;
Rect1.setWidth(5); Rect1.setHeight(7); Rect2.setWidth(12); Rect2.setHeight(2);
S
!"" $%&'()*+ &'+,'%-.'%/(0 1234
5556789:;8<987=:>=86?;@:
// Print the area of the object. cout<<")"+*2.'( '( )*+ )*(+"(1"#'.,"<
#. \0/1]4, 4-1#,' &'['
4