36.
Consider the following C++ code and answer the questions from (i) to (iv).
class Campus
{
long Id;
char City[20];
protected:
char Country[20];
public:
Campus();
void Register();
void Display();
};
class Dept : private Campus
{
long DCode[10];
char HOD[20];
protected:
double Budget;
public:
Dept();.
void Enter();
void Show();
};
class Applicant : public Dept
{
long RegNo;
char Name[20];
public:
Applicant();
void Enroll (C);
void View();
};
(i) Which type of inheritance is shown in the above example?
(ii) Write the names of those member functions, which are directly accessed from the objects of class Applicant.
(iii) Write the names of those data members, which can be directly accessed from the member functions of class Applicant.
(iv) Is it possible to directly call function Display( ) of class University from an object of class Dept? (Answer as Yes or No).
37.
Consider the following C++ code and answer the questions from (i) to (iv).
class University
{
long Id;
char City[20];
protected:
char Country[20];
public:
University();
void Register();
void Display();
};
class Department : private University
{
long DCode[10];
char HOD[20];
protected:
double Budget;
public:
Department();
void Enter();
void Show();
};
class Student : public Department
{
long Roll No;
public:
Student();
void Enroll();
void View();
};
(i) Which type of inheritance is shown in the above example?
(ii) Write the names of those member functions, which are directly accessed from the objects of class Student.
(iii) Write the names of those data members, which can be directly accessible from the member functions of class Student.
(iv) Is it possible to directly call function Display! ) °f class University from an object of class Department?
(Answer as Yes or No).
38.
Consider the following class State:
class State
{
protected:
int tp: //no. of tourist places
public:
State()
{
tp = 0;
}
void inctp()
{
tp++;
}
int gettp()
{
return tp;
}
}:
Write a code in C++ to publically derive another class ‘District’ with the following additional members derived in the public visibility’mode.
Data Members
• distname – char (50)
• population – long
Member functions
• dinput() — To enter distname and population.
• doutput() — To display distname and population on screen.
39.
Consider the following C + + code and answer the questions from (i) to (iv).
class Personal
{
int Class, Rno;
char Section;
protected:
char Name[20];
public:
Personal();
void Pentry();
void Pdisplay();
}:
class Marks : private Personal
{
float M[5];
protected:
char Grade[5];
public:
Marks();
void Mentry();
void Mdisplay():
};
class Result : public Marks
{
float Total, Agg;
public:
char FinalGrade, Comments[20];
ResultO() .
void Rcalculate();
void RdisplayO;
};
(i) Which type of inheritance is shown in the above example?
(ii) Write the names of those data members, which can be directly accessed from the objects of class Result.
(iii) Write the names of those member functions, which can be directly accessed from the objects of class Result.
(iv) Write the names of those data members, which can be directly accessed from the Mentry() function of class Marks.
40.
Consider the following C + + code and answer the questions from (i) to (iv).
class Student
{
int Class, Rno;
char Section; .
protected:
char SName[20];
public:
Student();
void Stentry();
void Stdisplay();
};
class Score : private Student
{
float Marks[5];
protected:
char Grade[5];
public:
Score();
void Sentry();
void Sdisplay();
};
class Report : public Score
{
float Total, Avg;
public:
char OverallGrade, Remarks[20];
Report();
void REvaluate();
void RPrint]);
};
(i) Which type of inheritance is shown in the above example?
(ii) Write the names of those data members, which can be directly accessed from the objects of class Report.
(iii) Write the names of those member functions, which can be directly accessed from the objects of class Report.
(iv) Write the names of those data members, which can be directly accessed from the Sentry() function of class Score.