EBK DATA STRUCTURES AND ALGORITHMS IN C
4th Edition
ISBN: 9781285415017
Author: DROZDEK
Publisher: YUZU
expand_more
expand_more
format_list_bulleted
Question
Chapter 1, Problem 12E
Program Plan Intro
Class Access Modifiers:
The feature of object oriented
There are three access specifiers used in class to restrict the access of members inside the class. They are as follows:
- Public
- Protected
- Private
For classes and members, the default access specifier is “private”.
Explanation of Solution
Possiblity of a variable “n” become as private, protected or public:
- In public derivation, each “public” and “protected” variable retains its status, that is, variable that is “public” in “classA” remains “public” in “classB”...
Explanation of Solution
Variables “m” and “k”:
- The status of some variables can be adjusted to the status this variable has in the base class...
Explanation of Solution
Derivation of class B
- In the public derivation of “classB”, protected variable “m” remains protected in “classB”, public variable “k” remains public in “classB”.
- In the protected derivation of “classB”, protected variable “m&...
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
An unspecified data type can be used
for both the parameters and the return type
just for abstract classes (because they can not be instantiated)
just for the signature of a method (i.e., the parameters)
O just for the non-signature parts of the method (i.e., the return type)
Explain why it is better to have accessors for private types rather than public types in no more than three sentences.
Explain why it is preferable to have accessors to private types rather than making the types public, keeping in mind the three reasons that are given below.
Chapter 1 Solutions
EBK DATA STRUCTURES AND ALGORITHMS IN C
Knowledge Booster
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
- Experiment with two classes that have a straightforward derivation relationship. Insert println statements into the constructors of both the parent and child classes. In the child, do not explicitly call the function Object() { [native code] } of the parent. So, what happens? Why? Change the child's function Object() { [native code] } to explicitly call the parent's function Object() { [native code] }. What happens next?arrow_forwardJustify the need for accessors for private types rather than public kinds using only three phrases.arrow_forwardJustify why it is desirable to have accessors to private types rather than making the types public for the following three reasons.arrow_forward
- Passing arguments to base classes constructors solves the problem of selecting a base class constructor in inheritance. Can the same problem arise with composition? That is, might there be a case where a constructor of a class might have to pass arguments to the constructor of a contained class? If so, guess the syntax that would be used to pass the parameters, and construct a simple example to verify your guess.arrow_forwardA. The members of classes can be protected by the access modifier, such as private, public, no access modifier (by default), or protected. What is the difference between public and no access modifiers (by default) in terms of packages? B.What is the relationship between the use case model and the static model for developing an object- oriented software system? C. We can implement dynamic method dispatch using inheritance or interface in Java. What is the difference between inheritance-based and interface- based dynamic method dispatch?arrow_forwardImplement the classes according to the given class diagram. It shows both the composition and aggregation relationships. Driver has a Vehicle and Engine is a part of that Vehicle. [Note: consider the necessary data members, constructors, destructors and member functions accordingly] Note: solve as soon as possible use C++ LANGUAGE Class diagram is givenarrow_forward
- Explain why accessors to private types are preferable than make the types public for the following three reasons.arrow_forwardWith appropriate examples, explain the features of static class members.arrow_forwardGiven these three arguments, please explain why it is better to have accessors for private types rather than making them public.arrow_forward
- Write program in C++ using inhertiance and polymorphism. A car dealership wants you to keep track of their sold and leased vehicles. You have realized that all vehicles have a make, model and vehicle identification number so you are going to factor those attributes out and put them in the base class as private attributes. Additionally you realize that you need to create two derived classes: one that keeps track of vehicles that are sold and the other that keeps track of ones that are leased. Vehicles that are sold have a sale date and sale amount. Vehicles that are leased have a monthly lease payment and terms of the lease (number of years). For all classes, create a proper overloaded constructor and display method that properly displays the class’s attributes. For your display method make sure you are using proper run-time polymorphism techniques so that your code calls the correct display methods. Complete main.cpp and follow comments for instruction Given code of .cpp and .h classes…arrow_forwardImplement the classes according to the given class diagram. It shows both the composition and aggregation relationships. Driver has a Vehicle and Engine is a part of that Vehicle. [Note: consider the necessary data members, constructors, destructors and member functions accordingly] Note: use OOP and C++arrow_forwardProblem B Now we are going to use the design pattern for collecting objects. We are going to create two classes, a class AmazonOrder that models Amazon orders and a class Item that models items in Amazon orders. An item has a name and a price, and the name is unique. The Item class has a constructor that takes name and price, in that order. The class also has getters and setters for the instance variables. This is the design pattern for managing properties of objects. The setName() method should do nothing if the parameter is the empty string, and the setPrice() method should do nothing if the parameter is not positive. The class also has a toString() method that returns a string representation for the item in the format “Item[Name:iPad,Price:399.99]”. For simplicity, we assume an Amazon order can have at most 5 items, and class AmazonOrder has two instance variables, an array of Item with a length of 5 and an integer numOfItems to keep track of the number of items in the…arrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education
Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education
Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education
Call By Value & Call By Reference in C; Author: Neso Academy;https://www.youtube.com/watch?v=HEiPxjVR8CU;License: Standard YouTube License, CC-BY