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
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.
Justify the need for accessors for private types rather than public kinds using only three phrases.
Justify why it is desirable to have accessors to private types rather than making the types public for the following three reasons.
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
- Explain why accessors are better than making secret types public in each of the following three situations.arrow_forwardGiven these three arguments, please explain why it is better to have accessors for private types rather than making them public.arrow_forwardTry out a straightforward derivational link between two classes. Put println statements in both the parent class's and the child class's constructors. Never explicitly call the parent's function Object() { [native code] } in the child. What transpires? Why? Make the parent's function Object() { [native code] } an explicit call in the child's function Object() { [native code] }. What happens next?arrow_forward
- Explain why accessors to private types are preferable than make the types public for the following three reasons.arrow_forwardAnswer the following questions about the given statement:{co : Customer |co.classcredit >3 ∧∃c : Course • (co,c) ∈Books ∧¬c.private}•What does this statement mean?•Is this statement a set or a predicate?•What does the statement evaluate to based on the current system state? Examples for reference:•∃g : Owner • g.name = gymowner ∧g.email = test-There exists an owner with the name gymowner and email test-predicate-false•{c : Course |∃co : Customer • (co,c) ∈Books}-Set of all Courses which are booked by a customer-set-{Boxing,WeightLifting,Yoga1,Wrestling}•{t : Trainer |#{c : Course |(t,c) ∈Teaches}>1}-Set of all Trainers who teach more than 1 class.-set-{Trainer 2}arrow_forwardAnswer the following questions about the given statement:∀c : Courses • ∃co : Customer • (co,c) ∈Books•What does this statement mean?•Is this statement a set or a predicate?•What does the statement evaluate to based on the current system state? Examples for reference:•∃g : Owner • g.name = gymowner ∧g.email = test-There exists an owner with the name gymowner and email test-predicate-false•{c : Course |∃co : Customer • (co,c) ∈Books}-Set of all Courses which are booked by a customer-set-{Boxing,WeightLifting,Yoga1,Wrestling}•{t : Trainer |#{c : Course |(t,c) ∈Teaches}>1}-Set of all Trainers who teach more than 1 class.-set-{Trainer 2}arrow_forward
- Answer the following questions about the given statement:{c : Course |∃co : Customer • (co,c) ∈Books ∧co.classcredit >2}•What does this statement mean?•Is this statement a set or a predicate?•What does the statement evaluate to based on the current system state? Examples for reference:•∃g : Owner • g.name = gymowner ∧g.email = test-There exists an owner with the name gymowner and email test-predicate-false•{c : Course |∃co : Customer • (co,c) ∈Books}-Set of all Courses which are booked by a customer-set-{Boxing,WeightLifting,Yoga1,Wrestling}•{t : Trainer |#{c : Course |(t,c) ∈Teaches}>1}-Set of all Trainers who teach more than 1 class.-set-{Trainer 2}arrow_forwardwrite the Z-Notation for these statements.-The set of all customers that did not book a class yet, which customers are in this set.-Set of all Courses with the type Yoga that are booked by a customer. Which coursesare in this set.-Predicate that evaluates to true if there is a customer who booked at least 2 classes.Is this true or false?arrow_forwardConsider the following declarations: (1, 2, 5, 7) How many members does class foodType have? How many private members does class foodType have? How many constructors does class foodType have? How many constant functions does class foodType have? Which constructor is used to initialize the object fruit1? Which constructor is used to initialize the object fruit2? Rewrite the definition of the class foodType so that each data member can be set individually. Write a C++ statement to replace the definition of the constructors with a constructor with default parameter.arrow_forward
- Give an example where if we do not provide copy constructor, behavior of the programbecomes unacceptable. C++arrow_forwardDesign a Java class named LinearEquation for a 2-by-2 system of linear equations:ax + by = e x=(ed-bf)/(ad-bc)cx + dy = f y=(af-ec)/(ad-bc) The class contains:• Private double data fields a, b, c, d, e, and f.• A constructor with the arguments for a, b, c, d, e, and f.• Six getter methods for a, b, c, d, e, and f.• Methods getX() and getY() that return the solution for the equation.• A method named isSolvable() that returns true if ad - bc is not 0. The method isSolvable() willbe called in the main, if it returns true display the calculated values for x and y by calling getX()and getY(). If the call to isSolvable() returns false, display a message that “the equation has nosolution”. Write a Java program that prompts the user to enter a, b, c, d, e, and f and displays the result. After the valuesfor a through f are entered, create a LinearEquation object. Check to seeIf ad - bc is 0, report that “The equation has no solution”, otherwise print out the values for x and y.arrow_forwardQ2: Consider the following statements: public class YClass { private int a; private int b; public void one() { } public void two(int x, int y); { } public YClass() { } } class XClass extends YClass { private int z; public void one() { } public XClass() { } } YClass yObject; XClass xObject; Write the definition of the default constructor of YClass so that the instance variables of YClass are initialized to 0. Write the definition of the default constructor of XClass so that the instance variables of XClass are initialized to 0. Write the definition of the method two of YClass so that the instance variable a is initialized to the value of the first parameter of two and the instance variable b is initialized to the value of the second parameter of two. please I want solution :(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
Call By Value & Call By Reference in C; Author: Neso Academy;https://www.youtube.com/watch?v=HEiPxjVR8CU;License: Standard YouTube License, CC-BY