Search This Blog

Tuesday, 13 November 2012

In the above case when we have same member in both the base and derived.

#include<iostream.h>
#include<conio.h>
class student
{
int rlno;
public:
void getData()
{
cout<<"Get Roll Number";
cin>>rlno;
}
void putData()
{
cout<<"Roll Number="<<rlno<<"\n";
}
};
class mark:public student
{
int mark;
public:
void getData()
{
Student::getData();
cout<<"Get Mark";
cin>>mark;
}
void putMark()
{
cout<<"Mark="<<mark<<"\n";
}
};
void main()
{
mark M;
M.getData();
M.putData();
M.putMark();
getch();
}
Get Roll Number
121
Get Mark
78
Rollno=121
Mark=78

No comments:

Post a Comment