What is the difference between an interface, class and an instance of the class? b) Is it a good idea to make member variables private? Why or why not? c) What is a constructor? Is it possible to have more than one constructor?

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

(Hand Written Submission) 

 

Question # 1

a) What is the difference between an interface, class and an instance of the class?
b) Is it a good idea to make member variables private? Why or why not?
c) What is a constructor? Is it possible to have more than one constructor?
d) What is the difference between static data member and an instance data member?
e) What is the difference between composition and aggregation?

 

Question # 2 


Write a program to model the kinds of people one finds in a university. The categories are students,
teachers and teaching assistant (TAs). All these categories are kinds of Person (Person is abstract class. A
teaching assistant (TA) is a student and a teacher as well.
A person has a name (string). A student has grade point average GPA (between 0 to 4), the teacher has
the number of scholarly papers he/she has published and the teacher assistant has the number of courses
he/she assists.
All the classes contain constructors with default arguments to fill all data spaces. Provide displaymethod
to print all data members of an object on the screen. Classes also contain a function called isSuccessful().
Students with a GPA over 3.5 are considered successful. Thisfunction returnstrue ifsomeone issuccessful
or false if not.
In main(), define an array of Person class, which can point to students, teachers and teacher assistants. The
program first asks the kind of person and then lets the user enter the name. For students, the program also
asks the GPA; for teacher, its ask for the number of publications and for teacher assistants it asks the
number of courses additionally.
The maximum number of object, which can be kept in the array, is 10. When the user is finished, the
program prints out the names and other data for all persons. It also prints whether a person is successful
or not. Delete the array in the end.

Output:

----------------------------------------------------------------------------------

Enter student, teacher, assistant
(s/t/a): s
Enter name: Umar
Enter GPA: 1.5
Enter another (y/n)?
y
Enter student, teacher, assistant
(s/t/a): t
Enter name: Ahmed
Enter number of publications:
75
Enter another (y/n)?

----------------------------------------------------------------------------------

1. Write all necessary classes (including their methods).
2. Write the main program which will give the above output.
3. Store the output in output.txt file using Filing.

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 4 steps

Blurred answer
Knowledge Booster
Class
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
C++ for Engineers and Scientists
C++ for Engineers and Scientists
Computer Science
ISBN:
9781133187844
Author:
Bronson, Gary J.
Publisher:
Course Technology Ptr