0% found this document useful (0 votes)
630 views1 page

UTA018 LabAssignment-5

This document outlines 5 questions for a C++ lab assignment covering object-oriented programming concepts like inheritance, abstract base classes, and virtual functions/classes. Q1 involves defining classes Student, Marks, and Result using inheritance to store and display student roll numbers, names, subject marks, totals, and pass/fail results. Q2 defines classes Alpha, Beta, and Gamma where Gamma inherits from Alpha and Beta using multiple inheritance and uses constructors and destructors. Q3 defines classes X, Y, and Z where Z inherits and concatenates string data from X and Y using multiple inheritance and constructors/destructors. Q4 implements the "diamond problem" of hybrid inheritance making

Uploaded by

UMANG SHARMA
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
0% found this document useful (0 votes)
630 views1 page

UTA018 LabAssignment-5

This document outlines 5 questions for a C++ lab assignment covering object-oriented programming concepts like inheritance, abstract base classes, and virtual functions/classes. Q1 involves defining classes Student, Marks, and Result using inheritance to store and display student roll numbers, names, subject marks, totals, and pass/fail results. Q2 defines classes Alpha, Beta, and Gamma where Gamma inherits from Alpha and Beta using multiple inheritance and uses constructors and destructors. Q3 defines classes X, Y, and Z where Z inherits and concatenates string data from X and Y using multiple inheritance and constructors/destructors. Q4 implements the "diamond problem" of hybrid inheritance making

Uploaded by

UMANG SHARMA
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
You are on page 1/ 1

Lab Assignment-5

UTA018: Object Oriented Programming

Topics covered: Inheritance, abstract base class and virtual functions/class

Q1. Class Student contains data members RollNo and Name as protected. Member functions
GetDetails() to RollNo and Name and DisplayDetails() to display RollNo and Name.
Class Marks is publicly inherited from Student. It contains protected data member Subject1 and
Subject2 i.e. marks obtain in two subjects and GetMarks() and DisplayMarks() are two public
member functions.
Class Result is publicly inherited from Mark. It contains private data member TotalMarks and
two public methods CalculateResult( ) and DisplayResult() with status whether the student has
“PASSED” or “FAILED”.
Write a C ++ program to show the results according to the following formats:
Enter the number of students: 2
Enter student roll number: 1
Enter name of the student: A
Enter the marks of subject 1: 27
Enter the marks of subject 1: 32

Enter student roll number: 2


Enter name of the student: B
Enter the marks of subject 1: 65
Enter the marks of subject 1: 45

Roll No. Name Subject1 Subject2 Total Marks Obtained Result


--------------------------------------------------------------------------------------------------------------
1 A 27 32 59 FAILED
2 B 65 45 110 PASSED
--------------------------------------------------------------------------------------------------------------

Make the necessary assumptions with comments.

Q2. Implement a C++ program to define three classes Alpha, Beta and Gamma, each class
having private data members. Gamma is a class derived from Alpha and Beta (by applying
multiple inheritance). Use constructors and destructors to read and display data.

Q3. Write a program to define class X, Y and Z. Each class contains one character array as a data
member. Using multiple inheritance, concatenate strings of class X and Y and store it in class Z.
Using constructor and destructors, show all the three strings.

Q4. Write a C++ program to implement the diamond problem (hybrid inheritance). State the
necessary assumptions using comments.

Q5. Write a C++ program creating an abstract class Student. Create three derived classes
Science, Art and Commerce from the base class. Create the objects of the derived classes and
process them and access them using array of pointer of type Student.

****

You might also like