C++ How to Program (10th Edition)
10th Edition
ISBN: 9780134448237
Author: Paul J. Deitel, Harvey Deitel
Publisher: PEARSON
expand_more
expand_more
format_list_bulleted
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
This is object oriented programming
Language is C++
Consider the following scenario of a class Person. A Person class has a Name, ID, Address and has functions of change the address and profile display. (Hint: Composition is not applied)
Two classes are derived from this class person. 1) Student 2) Employee.
The student class has a course number, classes attended, year (freshman=1, sophomore=2 and so on), and functions to change course and profile display.
The employee class has a Date of joining and date of promotion.
The employee class further has two child classes 1) Faculty 2) Admin.
Faculty class has a course number, classes taught, Rank (AP, lecturer etc) and a function to display profile.
Admin class has number of projects worked on and a display profile function.
Answer the questions based on this scenario.
Make the classes as mentioned above. Make appropriate constructors and functions. Choose access type wisely.
programming language : C++
subject : object oriented programming
question:
We know that an Organization consists of Managers and Employees. You are required to create a base class Person with attributes name, CNIC and gender. Derive Manager and Employee class from Person class.
Question 2
(Student Inheritance Hierarchy) Draw a UML class diagram for an inheritance hierarchy for students at
a university similar to the hierarchy shown in Fig. 11.2. Use Student as the base class of the hierarchy,
then extend Student with classes UndergraduateStudent and GraduateStudent. Continue to extend the
hierarchy as deeply (i.e., as many levels) as possible. For example, Freshman, Sophomore, Junior and
Senior might extend UndergraduateStudent, and DoctoralStudent and MastersStudent might be derived
classes of GraduateStudent. After drawing the hierarchy, discuss the relationships that exist between the
classes.
Chapter 11 Solutions
C++ How to Program (10th Edition)
Ch. 11 - Exercises11.3 (Composition as an Alternative to...Ch. 11 - (Inheritance Advantage) Discuss the ways in which...Ch. 11 - (Protected vs. Private Base Classes) Some...Ch. 11 - Prob. 11.6ECh. 11 - Prob. 11.7ECh. 11 - (Quadrilateral Inheritance Hierarchy) Draw an...Ch. 11 - Package Inheritance Hierarchy} Package-delivery...Ch. 11 - (Account Inheritance Hierarchy) Create an...
Knowledge Booster
Similar questions
- Consider the definition of the class product Type as given in Exercise 8. Which function members are accessors and which are mutators? (4)arrow_forward(Richer Shape Hierarchy) The world of shapes is much richer than the shapes included inthe inheritance hierarchy of Fig. 19.3. Write down all the shapes you can think of—both two-dimensional and three-dimensional—and form them into a more complete Shape hierarchy with asmany levels as possible. Your hierarchy should have the base class Shape from which class TwoDimensionalShape and class ThreeDimensionalShape are derived. [Note: You do not need to write any codefor this exercise.] We’ll use this hierarchy in the exercises of Chapter 20 to process a set of distinctshapes as objects of base-class Shape. (This technique, called polymorphism, is the subject ofChapter 20.)arrow_forwardusing c++arrow_forward
- Define a class for the marks (student subject marks) that includes the following data members: A (OOP) B (Data Structures) C (Calculus II) The class also contains the following member functions: Insertion function – to get three values (courses). Sum - to sum up three values (courses). Ave – to give average of the three values (courses). Display function - to display sum and average. NOTE:subject: object oriented programming(oop) Deptt:CS/ITarrow_forwardQ2\B\ True or false ( answer three) 1- Abstract data types cannot be implemented in procedural languages such as C and Pascal. 2- Although methods and fields can be static, constructors cannot be static. 3- One problem with OOP when create a Class it can never be changed. 4- polymorphysim is extensively used in implementing inheritance.arrow_forwardLANGUAGE : C++ QUESTION : make a class of Student with attributes StudentName, Enrollment, semester, section, course MarksObtained and Grade. Write appropriate constructors, get and set functions for data members. The data member grade is automatically calculated based on marks obtained out of 100 for each course. also print out the outputsarrow_forward
- SUBJECT: OOPPROGRAMMING LANGUAGE: C++ ALSO ADD SCREENSHOTS OF OUTPUT. Write a class Distance to measure distance in meters and kilometers. The class should have appropriate constructors for initializing members to 0 as well as user provided values. The class should have display function to display the data members on screen. Write another class Time to measure time in hours and minutes. The class should have appropriate constructors for initializing members to 0 as well as user provided values. The class should have display function to display the data members on screen. Write another class which has appropriate functions for taking objects of the Distance class and Time class to store time and distance in a file. Make the data members and functions in your program const where applicablearrow_forwardWrite this C++ programme. Add 3 data members to the parent class and 2 to the child class to conduct inheritance. (data members in classes make sense). Parameterized constructors are required in parent classes. Child class constructors must give values to parent class constructors. Finally, construct a child class object and show its data on the console.arrow_forwardMark the following statements as true or false. a. In single inheritance, a base class can create only one derived class. (1) b. The public members of a base class can only be inherited as public members in the derived class. (2) c. To redefine (or override) a member function of the base class in the derived class, the corresponding member function must have the same name, number, and type of parameters. (3) d. If the derived class does not override a public member function of the base class, you may specify a call to that public member function by using the name of the function and the appropriate parameter list. (3) e. The constructor of a derived class can specify a call to the constructor of the base class in the heading of the function definition. (4) f. The constructor of a derived class can specify a call to the constructor of the base class using the name of the class. (4) g. Suppose that x and y are classes, one of the member variables of x is an object of type y, and both classes have constructors. The constructor of x specifies a call to the constructor of y by using the object name of type y. (4) h. When the destructor of the derived class executes, it automatically invokes the destructor of the base class. (5) i. The class ios is the base class for all stream classes. (7) j. In protected inheritance, the private members of the base class are protected members of the derived class. (8) k. In composition, one or more members of a class are objects of another class type. (9)arrow_forward
- QUESTION 4 (use c++ to answer the following question) Note: You need to add required constructors/destructors, member functions or data members/variables in your program to complete its execution. Suppose we are designing a record-keeping program that has records for salariedemployees and hourly employees. There is a natural hierarchy for grouping these classes.These are all classes of people who share the property of being employees.Employees who are paid an hourly wage are one subset of employees. Anothersubset consists of employees who are paid a fixed wage each month or week. Although the program may not need any type corresponding to the set of all employees, thinking in terms of the more general concept of employees can be useful. For example, all employees have names, Social Security numbers (ssn) and net pay, and the member functions for setting and changing the name, ssn and netpay would be same for both hourly and salaried employees. Implement the above mentioned…arrow_forwardOOP Homework Inheritance (PYTHON) 1. Given two classes as described in Customer.py (attached) Revise the class using inheritance to simplify the codes and to remove repetition of codes. Package-delivery services, such as FedEx®, DHL® and UPS®, offer a umber of different shipping options, each with specific costs associated. Create an inheritance hierarchy to represent various types of packages. Output: Sender: Ellen Abberton WR10 Recipient: Dane Abbey Dore, HR2 Cost: £40e Sender: Mike Agglethorpe DL8 Recipient: Andy Acton Bridge, CW8 Cost: £68e Sender: Andy Acton Bridge CW8 Recipient: Luke Abingworth, RH20 Cost: £61earrow_forwardSUBJECT: OBJECT ORIENTED PROGRAMMING WRITE CODE IN C++arrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- C++ Programming: From Problem Analysis to Program...Computer ScienceISBN:9781337102087Author:D. S. MalikPublisher:Cengage Learning
C++ Programming: From Problem Analysis to Program...
Computer Science
ISBN:9781337102087
Author:D. S. Malik
Publisher:Cengage Learning