You are on page 1of 3

EXPERIMENT – 19 DATE :15-12-2022

AIM: Write a program to demonstrate Multi Level Inheritance.

SOURCE CODE:

#include <iostream>

using namespace std;

class a{

char name[20];

int roll;

public:

void get_val1()

{ cout<<"Enter name:

"; cin>>name;

cout<<"Enter roll number: ";

cin>>roll;

void display1(){

cout<<"The details of the entered student is: "<<endl;

cout<<"Name: "<<name<<endl;

cout<<"Roll No.: "<<roll<<endl;

};

class b:public

a{ char

branch[20]; int

year;
public:

void get_val2(){

get_val1();

cout<<"Enter branch: ";

cin>>branch;

cout<<"Enter year of admission: ";

cin>>year;

void display2(){

display1();

cout<<"Branch: "<<branch<<endl;

cout<<"Year of admisssion: "<<year<<endl;

};

class c:private

b{ char

group[20];

public:

void get_val3(){

get_val2();

cout<<"Enter your group: ";

cin>>group;

void display3(){

display2();

cout<<"Group: "<<group<<endl;

};
int

main()

{ c l;

cout<<endl;

cout<<"Enter the details of the student "<<endl;

l.get_val3();

l.display

3();

cout<<en

dl; return

0;

OUTPUT:

You might also like