/*
inheritance means inheriting properties from parent class by a child class .
*/
#include<iostream>
#include<conio.h>
class abc
{
public: int a,b;
void ab(int x,int y)
{
a=x;b=y;
cout<<"\nvalues for a:"<<a<<" and b:"<<b;
}
};
class derived:public abc
{
public :
void input()
{
int sum,mult;
cout<<"\nSum of a + b :"<<(a+b);
cout<<"\nMultiplication of a * b :"<<(a*b);
}
};
void main()
{
derived d;
d.ab(3,7);
d.input();
getch();
}
inheritance means inheriting properties from parent class by a child class .
*/
#include<iostream>
#include<conio.h>
class abc
{
public: int a,b;
void ab(int x,int y)
{
a=x;b=y;
cout<<"\nvalues for a:"<<a<<" and b:"<<b;
}
};
class derived:public abc
{
public :
void input()
{
int sum,mult;
cout<<"\nSum of a + b :"<<(a+b);
cout<<"\nMultiplication of a * b :"<<(a*b);
}
};
void main()
{
derived d;
d.ab(3,7);
d.input();
getch();
}
Ouput
No comments:
Post a Comment