LAB#7 OOP LAB-Section-C Date:16-12-2020 Topics Covered

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 2

LAB#7

OOP LAB-Section-C
Date:16-12-2020
Topics covered:

 Describe the structure of friend functions and friend classes.


 Use the practical concept of friend functions and friend classes

Problem Statement 1:
Write a Student class that can store Name, Student ID, Program, and marks of three different
subjects as S1, S2 and S3 Declare all the variable as private. Write a Friend class calculate to
calculate and store the GPA of the student. And then write suitable code to test your program.
Use formula (S1+S2+S3)/12 to calculate the GPA.

Problem Statement 2:
Write a base class Shape that has private data member width and height and public member
function setWidht(int) and setHeight(int).Write a friend class Rectangular that has a method to
calculate the area of rectangular.

Problem Statement3 :

To write a c++ program to get student details, total marks & average

Declare a class student.


Define three data members rollno, marks1 & marks2.
Declare and define the friend function get() to get input for data
members rollno, marks1 & marks2.
Declare the other class arts derived from student class.
Define one data member arts marks.
Declare and define the function getam() to input the arts mark.
Create a friend class result that is friend of Student and arts class.
Declare and define the function display() to find out the total and
average.
Declare the result class object & call the functions get(),getam() and
display().

You might also like