Create a free account on Computer Sir Ki Class and unlock access to valuable learning resources.
Exam Paper Downloads: After registering and logging in, you can download exam question papers in PDF format to practice and prepare for your exams.
Student Support: Get assistance with your doubts, queries, and questions related to your studies. Our support is here to help you understand topics and resolve your learning difficulties.
Register today and make your exam preparation easier and more effective!
Answer the questions (i) to (iv) based on the following:
class Teacher
{
int TCode;
protected:
char Name[20];
public:
Teacher();
void Enter(); void Show();
};
class Course
{
int ID;
protected:
Char Title[30];
public:
Course();
void Initiate();
void Display();
};
class Schedule: public Course, private Teacher
{
int DD,MM,YYYY;
public:
Schedule();
void Start();
void View();
};
void main()
{
Schedule S;
}
(i) Which type of Inheritance out of the following is illustrated in the above example?
Single Level Inheritance, Multilevel Inheritance, Multiple Inheritance
(ii) Write the names of all the members, which are directly accessible by the member
function View() of class Schedule.
(iii) Write the names of all the members, which are directly accessible by the object S
of class Schedule declared in the main() function.
(iv) What will be the order of execution of the constructors, when the object S of class
Schedule is declared inside main() function?
Answer:
(i) Multiple Inheritance
(ii) Members accessible by function View() of class Schedule Start(), DD, MM, YYYY, Display(), Initiate(), Title, Enter(), Show(), Name, View()
(iii) Members accessible by object S of class Schedule: View(),Start(),Display(), Initiate() (iv) Order of execution of constructors for object S. Course(), Teacher(), Schedule()
Notes:
(i) Multiple Inheritance It is multiple inheritance because class Schedule is Inherited from more than 1 parent class which is Course and Teacher
(ii) Members accessible by function View() of class Schedule Start(), DD, MM, YYYY, Display(), Initiate(), Title, Enter(), Show(), Name, View()
The function View is within the class so all the public and protected members of Parent classes will be accessible (whether inherited publicly or privately) and all the members of the same class will be accessible.
(iii) Members accessible by object S of class Schedule: View(),Start(),Display(), Initiate()
The object S is outside the class, so only public members of same class and public members of parent class would be accessible.
(iv) Order of execution of constructors for object S. Course(), Teacher(), Schedule()
Constructors of parent classes will execute first with the order in which they are inherited and then the constructor of class itself will execute.
C. Sir| Created: 4-Dec-2018 | Updated: 22-Mar-2026|CBSE12A-2018