Answer to Question #14994 in C++ for himanshu

Question #14994
#include<iostream.h>
#include<conio.h>
class emp
{
protected:
int id;
int a;
void get()
{
cout<<"enter the id";
cin>>id;
}


};
class more:protected emp
{
public:
long pin;
char add[50];
void take()
{
cout<<"enter the pincode";
cin>>pin;
cout<<"enter the address";
cin>>add;


}

};
class more1:protected more

{
char name[50];
public:
void t()
{
cout<<"enter the name";
cin>>name;
take();
get(); //but get() function of class emp not accessable WHY?

}
void acc()
{ cout<<"enter the value of a"; //a is variable of class emp which is accessable
cin>>a;

}
void dis()
{
cout<<"\t"<<id<<"\t"<<name<<"\n"<<pin<<"\t"<<add<<"\t"<<a;
}
};

void main()
{
more1 m;
clrscr();

m.t();

m.acc();
m.dis();
getch();
}
0
Expert's answer

Answer in progress...

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
APPROVED BY CLIENTS