Oops 6 8 9 Sudha
Oops 6 8 9 Sudha
#include<iostream>
class num
private:
int a,b,c,d;
public:
a=j;
b=k;
c=m;
d=l;
void show(void);
void operator++();
};
cout<<a<<"\n"<<b<<"\n"<<c<<"\n"<<d;
}
void num::operator ++()
++a;++b;++c;++d;
int main()
num X(3,2,5,7);
X.show();
++X;
X.show();
return 0;
OUTPUT
(b).Write a program to demonstrate binary operator.
#include<iostream>
class number
public:
int x;
int y;
number() {}
x=j;
y=k;
number T;
T.x=x+D.x;
T.y=y+D.y;
return T;
void show()
{
cout<<x<<"\n"<<y;
};
int main()
number a(2,3),b(4,5),c;
a.show();
b.show();
c=a+b;
c.show();
OUTPUT
PROGRAM-9
#include<iostream>
class A1
protected:
int a1;
};
protected:
int a2;
};
protected:
int a3;
};
int a4;
public:
void get()
cin>>a1>>a2>>a3>>a4;
void put()
cout<<"a1="<<a1<<"a2="<<a2<<"a3="<<a3<<"a4="<<a4;
};
int main()
A4 a;
a.get();
a.put();
OUTPUT
PROGRAM-8
#include<iostream>
class A
protected:
int a;
};
class B
protected:
int b;
};
class C
protected:
int c;
};
class D
protected:
int d;
};
int e;
public:
void getdata()
cin>>a>>b>>c>>d>>e;
void show()
cout<<a<<b<<c<<d<<e;
}};
int main()
E x;
x.getdata();
x.show();
}
OUTPUT
8(b).WAP to demonstrate hybrid inheritance.
#include<iostream>
class aa {
protected:
int a, a1;
};
class bb : public aa {
protected:
int b;
public:
void show() {
};
class cc : public aa {
protected:
int c;
public:
void show2() {
};
int main() {
bb ob1;
ob1.show();
cc ob2;
ob2.show2();
return 0;
OUTPUT
8(c). WAP to show hierarchical inheritance.
#include<iostream>
class Red {
public:
Red() {
};
class Yellow {
public:
Yellow() {
};
class Blue {
public:
Blue() {
};
class Orange : public Red, public Yellow {
public:
Orange() {
};
public:
Green() {
};
class Violet {
public:
Violet() {
};
int main() {
Violet v;
endl(cout);
Green g;
endl(cout);
Orange o;
endl(cout);
return 0;
OUTPUT