Sunteți pe pagina 1din 25

OBJECT ORIENTED PRGRAMMING

ASSIGNMENT

NAME : ADEEL AHMAD


ROLL No. : 8909
CLASS : BSSE (3rd SEMESTER)

SUBMITTED TO = MAAM HIRA ASHFAQ


1
#include <iostream>
using namespace std;
class test
{
private:
int n;
public:
test()
{
n=0;
}
void show()
{
cout<< "n = " << n <<endl;
}
void operator ++()
{
n++;
}
};
int main()
{
test t;
t.show();
++t;

2
t.show();

}
________________________________________________________
#include <iostream>

using namespace std;

class test
{
private:
int n;
public:
test()
{
n=0;
}
void show()
{
cout<< "n = " << n <<endl;
}
void operator --()
{
n--;
}

3
};
int main()
{
test t;
t.show();
--t;
t.show();
}
________________________________________________________
#include <iostream>

using namespace std;

class test
{
private:
int n;
public:
test()
{
n=0;
}
void show()
{
cout<< "n = " << n <<endl;

4
}
void operator ++(int)
{
n++;
}
};
int main()
{
test t;
t.show();
t++;
t.show();

}
________________________________________________________
____
#include <iostream>

using namespace std;

class test
{
private:
int n;
public:
test()

5
{
n=0;
}
void show()
{
cout<< "n = " << n <<endl;
}
void operator --(int)
{
n--;
}
};
int main()
{
test t;
t.show();
t--;
t.show();

}
________________________________________________________
___
#include<iostream>
using namespace std;

class test

6
{
private:
int n;

public:

void gettest(int x)
{
n=x;
}

void displaytest(void)
{
cout << "value of n is: " << n;
}

void operator - (void)


{
n=-n;
}
};

int main()
{
test num;

7
num.gettest(10);
-num;
num.displaytest();
cout << endl;
return 0;

}
________________________________________________________
_
#include <iostream>

using namespace std;

class add

private:

int a , b;

public:

8
add()

a=b=0;

void input()

cout<< "Enter value of A " <<endl;


cin>>a;
cout<< "Enter value of B " <<endl;
cin>>b;
}
void show()
{
cout << "A = " << a << endl;
cout << "B = " << b << endl;

}
add operator +(add p)

9
{ add temp;
temp.a=p.a+a;
temp.b=p.b+b;
return temp;

};

int main()

add x,y,z ;
x.input();
y.input();
z=x+y;
x.show();
y.show();
z.show();

}
________________________________________________________
#include <iostream>

10
using namespace std;

class sub

private:

int a , b;

public:

sub()

a=b=0;

11
void input()

cout<< "Enter value of A " <<endl;


cin>>a;
cout<< "Enter value of B " <<endl;
cin>>b;
}
void show()
{
cout << "A = " << a << endl;
cout << "B = " << b << endl;

}
sub operator -(sub p)

{ sub temp;
temp.a=p.a-a;
temp.b=p.b-b;
return temp;

};

12
int main()

sub x,y,z ;
x.input();
y.input();
z=y-x;
x.show();
y.show();
z.show();

}
________________________________________________________
#include <iostream>

using namespace std;

class product

13
{

private:

int a , b;

public:

product()

a=b=0;

void input()

cout<< "Enter value of A " <<endl;


cin>>a;
cout<< "Enter value of B " <<endl;
cin>>b;
}

14
void show()
{
cout << "A = " << a << endl;
cout << "B = " << b << endl;

}
product operator *(product p)

{ product temp;
temp.a=p.a*a;
temp.b=p.b*b;
return temp;

};

int main()

product x,y,z ;
x.input();
y.input();
z=y*x;

15
x.show();
y.show();
z.show();

}
________________________________________________________
#include <iostream>

using namespace std;

class divide

private:

float a , b;

public:

16
divide()

a=b=0;

void input()

cout<< "Enter value of A " <<endl;


cin>>a;
cout<< "Enter value of B " <<endl;
cin>>b;
}
void show()
{
cout << "A = " << a << endl;
cout << "B = " << b << endl;

}
divide operator /(divide p)

17
{ divide temp;
temp.a=p.a/a;
temp.b=p.b/b;
return temp;

};

int main()

divide x,y,z ;
x.input();
y.input();
z=y/x;
x.show();
y.show();
z.show();

}
________________________________________________________

18
#include <iostream>

using namespace std;

class mod

private:

19
int a , b;

public:

mod()

a=b=0;

20
void input()

cout<< "Enter value of A " <<endl;

cin>>a;

cout<< "Enter value of B " <<endl;

cin>>b;

void show()

cout << "A = " << a << endl;

21
cout << "B = " << b << endl;

mod operator %(mod p)

{ mod temp;

temp.a=p.a%a;

temp.b=p.b%b;

return temp;

22
};

int main()

mod x,y,z ;

x.input();

y.input();

z=y%x;

x.show();

y.show();

z.show();

23
}

24

S-ar putea să vă placă și