Define two class types: Student and Graduate, where Graduate inherits from St udent. Class Student includes (1) member variables: name, id, and score (protected) (2) member functions: (public) a default constructor Student:Student(): name("no name"), id(0), score (0) constructor Student:Student(string n, int i, double s): name(n), id(i), scor e(s). void output() Class Graduate has (1) additional member variables: string supervisor; (private) (2) additional member functions: (public) a default constructor Graduate::Graduate(): Student(),supervisor("no na me") constructor Graduate: Graduate (string n, int i, double s, string sn): Stude nt(n,I,s), supervior(sn). void output() ---redefine the function Define three graduate student g1, g2,g3 in main function (1) Input the information for g1 from the keyboard; (2) Initialize the information for g2 when it is declared (using default construct or); (3) Initialize the information for g3 when it is declared (using normall construct

C++ Programming: From Problem Analysis to Program Design
8th Edition
ISBN:9781337102087
Author:D. S. Malik
Publisher:D. S. Malik
Chapter10: Classes And Data Abstraction
Section: Chapter Questions
Problem 7SA: Assume the definition of class foodType as given in Exercise 6. Answer the following questions? (1,...
icon
Related questions
Question
100%

Please solve the Programming problem. Two images attached accordingly. 

Define two class types: Student and Graduate, where Graduate inherits from St
udent.
Class Student includes
(1) member variables: name, id, and score (protected)
(2) member functions: (public)
a default constructor Student::Student(): name("no name"), id(0), score
(0)
constructor Student:Student(string n, int i, double s): name(n), id(i), scor
e(s).
void output()
Class Graduate has
(1) additional member variables: string supervisor; (private)
(2) additional member functions: (public)
a default constructor Graduate:Graduate(): Student(),supervisor("no na
me")
constructor Graduate:: Graduate (string n, int i, double s, string sn): Stude
nt(n,l,s), supervior(sn).
void output() ---redefine the function
Define three graduate student g1, g2,g3 in main function
(1) Input the information for g1 from the keyboard;
(2) Initialize the information for g2 when it is declared (using default construct
or);
(3) Initialize the information for g3 when it is declared (using normal construct
Transcribed Image Text:Define two class types: Student and Graduate, where Graduate inherits from St udent. Class Student includes (1) member variables: name, id, and score (protected) (2) member functions: (public) a default constructor Student::Student(): name("no name"), id(0), score (0) constructor Student:Student(string n, int i, double s): name(n), id(i), scor e(s). void output() Class Graduate has (1) additional member variables: string supervisor; (private) (2) additional member functions: (public) a default constructor Graduate:Graduate(): Student(),supervisor("no na me") constructor Graduate:: Graduate (string n, int i, double s, string sn): Stude nt(n,l,s), supervior(sn). void output() ---redefine the function Define three graduate student g1, g2,g3 in main function (1) Input the information for g1 from the keyboard; (2) Initialize the information for g2 when it is declared (using default construct or); (3) Initialize the information for g3 when it is declared (using normal construct
(3) Initialize the information for g3 when it is declared (using normal construct
or);
int main()
{ string name;
int id;
double score;
string supervior;
Graduate g1,g2,g3("Tom", 1,90,"Peter");
cin<<name<<id<<socre<<supervior,
g1=Graduate(name,id,socre,supervior);
g1.output();
g2.output);
g3.output();
return 0;
Transcribed Image Text:(3) Initialize the information for g3 when it is declared (using normal construct or); int main() { string name; int id; double score; string supervior; Graduate g1,g2,g3("Tom", 1,90,"Peter"); cin<<name<<id<<socre<<supervior, g1=Graduate(name,id,socre,supervior); g1.output(); g2.output); g3.output(); return 0;
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps with 1 images

Blurred answer
Knowledge Booster
Unreferenced Objects
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning
Programming Logic & Design Comprehensive
Programming Logic & Design Comprehensive
Computer Science
ISBN:
9781337669405
Author:
FARRELL
Publisher:
Cengage
C++ for Engineers and Scientists
C++ for Engineers and Scientists
Computer Science
ISBN:
9781133187844
Author:
Bronson, Gary J.
Publisher:
Course Technology Ptr