hello,
yesterday i was learning inheritance in C++...
My teacher has told me that
"Inheritance means using properties(variable,function etc) of one class to another class."
but when i do it with example its not working..
#include<iostream.h>
#include<stdio.h>
class abc
{
int a,b,c;
public:
void exp1();
};
class xyz:public abc
{
public:
void exp2();
};
void abc::exp1()
{
cout<<"Enter Value of a= ";
cin>>a;
cout<<"Enter Value of b= ";
cin>>b;
cout<<"Enter Value of c= ";
cin>>c;
}
void abc::exp2()
{
cout<<"a= "<<a;
cout<<"b= "<<b;
cout<<"c= "<<c;
}
void main()
{
clrscr();
abc a1;
xyz x1;
a1.exp1;
x1.exp2;
getch();
}
As definition says, i had used the variables of class abc in class xyz, making class abc as public..
so, any problem in my program or in my concept.