0% found this document useful (0 votes)
5 views2 pages

Assignment 2

The document contains a C++ program that defines a class hierarchy for capturing a person's biodata, including their name, phone number, academic qualifications, and extracurricular activities. It utilizes virtual inheritance to ensure that the base class 'Person' is only instantiated once in the derived classes 'Academics' and 'ExtraCirricular'. The main function prompts the user to enter the biodata for one person and displays the collected information.

Uploaded by

21questionpaper
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views2 pages

Assignment 2

The document contains a C++ program that defines a class hierarchy for capturing a person's biodata, including their name, phone number, academic qualifications, and extracurricular activities. It utilizes virtual inheritance to ensure that the base class 'Person' is only instantiated once in the derived classes 'Academics' and 'ExtraCirricular'. The main function prompts the user to enter the biodata for one person and displays the collected information.

Uploaded by

21questionpaper
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

Assignment-2

#include <iostream>
using namespace std;
class Person {
public:
string Name;
string PhoneNumber;
Person(){
cout <<"\n\nEnter Name of the person :";
cin >> Name;
cout <<"Enter Phone Number of the person :";
cin >> PhoneNumber;
}
};
class Academics: virtual public Person {
public:
string Degree;
float Percentage;
Academics(){
cout <<"Enter the Educational Qualification (Degree) of the person :";
cin >> Degree;
cout <<"Enter the Percentage obtained :";
cin >> Percentage;
}
};
class ExtraCirricular: virtual public Person {
public:
string Sport;
string Level;
ExtraCirricular(){
cout <<"Enter the Sports you play :";
cin >> Sport;
cout <<"Enter the level at which you play this game :";
cin >> Level;
}
};
class Biodata: public Academics, public ExtraCirricular {
public:
Biodata(){
cout <<"\n~~~~~ Biodata of the Person ~~~~~";
cout <<"\nName :"<<Name<<endl;
cout <<"Phone Number :"<<PhoneNumber<<endl;
cout <<"Degree :"<<Degree<<endl;
cout <<"Percentage :"<<Percentage<<endl;
cout <<"Sport :"<<Sport<<endl;
cout <<"Level :"<<Level<<endl;
cout <<"-----------------------------------------------";
}
};
int main(){
cout <<"Enter Biodata of person 1";
Biodata P1;
return 0;
}
Output

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy