EXPERIMENT 3: Program to Find greatest no using Inheritance .
INHERITANCE: Inheritance is a process of creating new class from existing classes. New class inherit some of the properties and behavior of the existing class.An exixting class That is “parent” of New classis called base class.
EXP:Write a program in c++ single level inheritance
#include<iostream>
using namespace std;
class A{ protected: int x,y,z;
input() { cout<<“Enter three No “; cin>>x>>y>>z; }
};
class B:public A
{ int great;
public:
maximum()
{ input(); // call input fun
great=x>y&&x>z?x:y>z?y:z;
cout<<“\nGreatest no is:-“<<great;
} };
int main()
{ B obj;
obj.maximum();
return 0;
}
OUTPUT: Enter three no: 45 56 22
Greatest no is 56