Beruflich Dokumente
Kultur Dokumente
Protected No Yes
Private No No
Visibility Mode
Public Derivation Public Members – Public
Protected Members – Protected
Private Members – Private
class Y
class X class Y :protected X {
{ { int a;
int a; int p; int p;
protected: protected: protected:
int b; int q; int q;
void Input(); void Accept(); int b;
public: public: void Input();
int c; int r; int c;
void Print(); void Show(); void Print();
}; }; void Accept();
public:
int r;
void Show();
};
Single Inheritance - Public Visibility
class X
class Y class Z: public X, public Y
{ { {
int a; int p; int I,
protected: protected: protected:
int b; int q; int j;
void Input(); void Accept(); void getdata();
2018 Outside
protected: public:
char name[20]; schedule();
public: void start();
teacher();
void enter(); };
void view();
Delhi
void show(); void main()
}; {
class course schedule s;
{ }
int id;
protected: 1. Which type of inheritance is illustrated in the example given.
char title[30]; 2. Write the names of all members which are directly accessible by the
public: member function view() of class schedule.
course(); 3. Write the names of all members ,which are directly accessible by Object
void Initiate(); S of class Schedule declared in the main() function.
void Display(); 4. What will be the order of execution of constructors when object S of class
}; schedule is declared inside main() function.
2017 Outside Delhi Answer the questions given below:- class Third : public Second
{
class First class Second : private First int z1;
{ { public:
int x1; int y1; Third();
protected: protected: void enter3();
float x2; float y2; void display();
public: public: };
first(); second();
void enter2(); void main()
void enter1(); {
void display1(); void display();
}; Third T; // Statement 1
}; _________ // Statement 2
1. Which type of inheritance is shown ? }
2. Write the names of all member functions accessible by object T .
3. Write statement2 to call function display() of class Second from object
T.
4. What will be the order of execution of constructors.
class item
{ class salepoint : public item , private trader
int id; {
2016 Outside Delhi
char iname[20]; char name[20],location[20];
protected: public:
float qty; salepoint();
public: void enterall();
item(); void viewall();
void enter(); };
void view();
};
class Regular
{
2009 OUTSIDE DELHI
char SchoolCode[10];
public:
void InRegular( );
void OutRegular( );
};
class Distance
{
char StudyCentreCode[5];
public:
void InDistance ( );
void OutDistance( );
};
Write names of all the member functions accessible from OutCourse function of
class Course.
Write name of all the members accessible through an object of class Course.
Is the function InRegular( ) accessible inside the function InDistance( )? Justify your
answer.
class Toys
{ char TCode[5];
protected:
2008 OUTSIDE DELHI
float Price;
void Assign(float);
public:
Toys();
void TEntry();
i) Which type of inheritance is shown in the above
void TDisplay(); };
class SoftToys: public Toys example?
{ char STName[20]; ii) How many bytes will be required by an object of the
float Weight;
class SoftToys?
public:
SoftToys (); iii) Write name of all the data member(s) accessible from
void STEntry(); member functions of class SoftToys.
void STDisplay();};
class ElectronicToys:public Toys iv) Write name of all the member functions, which are
{ char ETName[20]; accessible from an object of the class ElectronicToys.
int No_of_Batteries;
public:
ElectronicToys();
void ETEntry();
void ETDisplay();};
class Teacher
{ char TNo[5],TName[20],Dept[10];
int Workload;
2007 OUTSIDE DELHI
protected:
i) Which type of inheritance is depicted by the above
float Salary;
example?
void AssignSal(float);
public:
ii) Identify the member function(s) that cannot be called
Teacher();
directly from the objects of class School from the following:
void TEntry();
TEntry() , SDisplay(), SchEntry()
void TDisplay(); };
class Student
iii) Write name of all the member(s) accessible from
{ char Admno[10],SName[20],Stream[10];
member functions of class School.
protected:
int Attendance,TotMarks;
iv) If class School was derived privately form Class Teacher
public:
and privately form class Student, then, name the member
Student();
function(s) that could be accessed through Objects of class
void SEntry();
School.
void SDisplay();};
class School:public Student,public Teacher
{ char SCode[10],SchName[20];
public:
School();
void SchEntry();
void SchDisplay();};
Inheritance and Constructors & Destructors