Professional Documents
Culture Documents
OOP Pract. 17
OOP Pract. 17
OOP Pract. 17
Subject. OOP
..
·•- - -
·•--- -------
---·-
--•-·---•·
..
·•---
·-----
·•-
·•-
· -- -- ... --··
-- ----
---·
·-
·• -
·-
·• -
·- -·---·--
-----
·-
·•·-
-
·•-- -- ---
·•
·• --
·- - ---·---- -· - -
,, _ . 1
•
I -'- .
-'-
• . ::lb eore+,
; - - - - - - - t - - - - - - -'_ _ _ _ _ _ _ _ __ _ _ _ J
§ e J_ vQ I l , e c ) +,,
f ?.!Ge
o-12
, -
j
Coding C++ MENU
Auto saved at 01 :40:02
<iostream>
std;
Complex {
fHl vate :
float real;
fluc1l imag;
public :
Complex() : real(0),
0), imag(0) {}
vo1cl input() {
cout <<
cin >> real;
cin >> imag;
void output( ) {
(imag < 0)
cout << << real << imag <<
rnt main() {
Complex complex1, complex2, result;
cout <<
complex1 . input();
cout <<
complex2.input();
••
••
•~
1111111 a
111111
-·
Coding C++ MENU
Auto saved at 01 :40:18
<iostream>
std;
Complex {
p1-1vate :
float real;
float imag;
public :
VOlcl input() {
cout <<
cin >> real;
cin >> imag;
vo1cl output() {
(imag < 0)
cout << << real << imag <<
irH main() {
Complex complex1, complex2, result;
cout <<
complex1 . input();
cout <<
complex2.input();
••
••
II Tliai ,___ II .
1111111 ■ II .
111111 •
-
•m·
Compile Result
••
••
1·
II ,._ _ _ ., II .
1111111 ■ •
111111
-·
•m
Coding C++ MENU
Auto saved at 01 :45:16
<iostream>
std;
Complex
cout<<
cin>>num1 >>num2;
vo1cl display()
Complex c;
c.num1=c1.num1+c2.num1;
c.num2=c1.num2+c2.num2;
(c);
int main()
c1. accept();
c2.accept();
sum= c1+c2;
cout<<
cout<<
c1. di splay();
cout<<
c2.display();
cout<<
cout<<
sum. di splay();
Compile Result
lill ■■
111111
-·
Coding C++ RUN MENU
Auto saved at 01 :49:06
<iostream>
std;
FLOAT
{
floclt a;
pul)] l c :
FLOAT ( f lo,lt a)
{
->a=a;
}
};
1111 main()
{
FLOAT f1(10 . 10),f2(20 . 20);
cout<< <<f1+f2;
cout<< <<f1-f2;
cout<< <<f1*f2;
cout << <<f1 / f2;
o·,
Compile Result
Operator+ 30.3
Operator -10.1
Operator* 204.02
Operator/ 0.5
[Process completed - press Enter]
••
••
II
••••
111111
-
•m · "' II :--'I
,. .,I
.
\
Coding C++ MENU
Auto saved at 01 :50:48
<iostream>
std;
FLOAT
flo,1t a;
public :
FLOAT (f l ocit a)
{
->a=a;
(a - F.a);
(a / F.a);
int main()
FLOAT f1(40.40),f2(70.70);
1(40.40),f2(70.70);
cout<< <<f1+f2;
cout<< <<f1 - f2 ;
c out<< <<f1*f 2 ;
cout<< <<f1 / f2;
Compile Result
Operator+ 111.1
Operator -30.3
Operator* 2856.28
Operator/ 0.571429
[Process completed - press Enter]
••
••
II ,__, II .
1111111 •
1111·
BIi .. - \:
-e
. __,~ '
,., -. - · - -
. -
@ ◄ EN·MR ► ,
Coding C++ MENU
Auto saved at 01 :54:39
<est ring>
<iostream>
<string .h>
std;
CompareString {
publ1c :
(strcmp(str, s2.str) == 0)
1;
mt operator<=(CompareString s3)
(s1 == s2)
cout << s1.str <<
<< s2.str << endl;
{
cout << s1.str <<
<< s2.str << endl;
(s1 >= s2)
cout << s1 .str <<
<< s2.str << endl;
vo1cl testcase1()
{
CflcllStr1 [] =
chc11 str2[] =
CompareString s1(str1);
CompareString s2(str2);
compare(s1, s2);
}
vo1cl testcase2()
{
chM str1 [] =
chc11 str2[] =
Compile Result
••
••
....
.66- ,__,, II .
'
- - - ·. ,----
.
II Ea
.~.. y rn II .
.
••••
.
[ ]: ~
. --
111111 i
•
.
-
... .
'
II
..
'
.J
I
-· Xi C
...
.
.... '?'
i
~ -
◄
.
-·
\:
•
EN·MR
--
.
-
- :
►
• I
,
.
Coding C++ MENU
Auto saved at 02:00:13
<iostream>
<string.h>
std;
CompareString {
. pub l 1 c :
ch,:ff str[25];
(strcmp(str, s2.str) == 0)
1;
(s 1 == s2)
cout << s1 .str <<
<< s2.str << endl;
{
cout << s1 . str <<
<< s2.str << endl;
(s1 >= s2)
cout << s1.str <<
<< s2 . str << endl;
void testcase1()
{
ch.:ff str1 [] =
char str2[ ] =
CornpareString s1(str1);
CornpareString s2(st r2 );
compare(s1, s2);
}
vo1el testcase2()
{
char- str1 [] =
char- str2 [] =
••
••
'9,
~.
1 I
·C
~
- _,,,
'?'
-
V,
·•
--\ :--: -
◄ EN·MR
-.
.
► ,