Concept explainers
Examine the following classes. The table lists the variables that are members of the Third class (some are inherited). Complete the table by filling in the access specification each member will have in the Third class. Write “inaccessible" if a member is inaccessible to the Third class.
class First
{
private:
int a;
protected:
double b;
public:
long c;
};
class Second : protected First
{
private:
int d:
protected:
double e;
public:
long f;
};
class Third : public Second
{
private:
int g;
protected:
double h;
public:
1ong i ;
}
Member Variable |
Access Specification in Third cass |
a | |
b | |
c | |
d | |
e | |
f | |
g | |
h | |
i |
Want to see the full answer?
Check out a sample textbook solutionChapter 15 Solutions
Starting Out With C++: Early Objects (10th Edition)
Additional Engineering Textbook Solutions
Concepts Of Programming Languages
Java: An Introduction to Problem Solving and Programming (7th Edition)
Java How To Program (Early Objects)
Database Concepts (8th Edition)
Web Development and Design Foundations with HTML5 (8th Edition)
Computer Science: An Overview (12th Edition)
- What precisely are "static members" in a class? When and how may you use them to your advantage?arrow_forward1. Employee and ProductionWorker Classes Write an Employee class that keeps data attributes for the following pieces of information: Employee name Employee number Next, write a class named ProductionWorker that is a subclass of the Employee class. The ProductionWorker class should keep data attributes for the following information: Shift number (an integer, such as 1, 2, or 3) Hourly pay rate The workday is divided into two shifts: day and night. The shift attribute will hold an integer value representing the shift that the employee works. The day shift is shift 1 and the night shift is shift 2. Write the appropriate accessor and mutator methods for each class. Once you have written the classes, write a program that creates an object of the ProductionWorker class and prompts the user to enter data for each of the object’s data attributes. Store the data in the object, then use the object’s accessor methods to retrieve it and display it on the screen. 2. ShiftSupervisor Class In a…arrow_forwardThe base class constructors are called before derived class constructor so that the Derived class constructor can assume members of the base class object have already been initialized. answer choices True Falsearrow_forward
- If a class is derived privately from the parent class then . Select one: a.all members are accessible by the child class b.no members of the base class is inherited c.all the members are inherited by the child class but are inaccessible d.the compiler gives an errorarrow_forwardWhat is the difference between a class's static data member and a non-static data member?Give an example of why a static data member would be useful in the real world.arrow_forwardThere are two types of data members in a class: static and non-static. Provide an example of when it might be useful to have a static data member in the actual world.arrow_forward
- Complete the following table by filling in private, protected, public, or inaccessible in the right-hand column: In a private base class, this base class MEMBER access specification... ..becomes this access specification in the derived class. private protected publicarrow_forwardemployee and production worker classes write an employee class that keeps data attributes for the following pieces of information: • employee name • employee number next, write a class named productionworker that is a subclass of the employee class. the productionworker class should keep data attributes for the following information: • shift number (an integer, such as 1, 2, or 3) • hourly pay rate the workday is divided into two shifts: day and night. the shift attribute will hold an integer value representing the shift that the employee works. the day shift is shift 1 and the night shift is shift 2. write the appropriate accessor and mutator methods for each class. once you have written the classes, write a program that creates an object of the productionworker class and prompts the user to enter data for each of the object’s data attributes. store the data in the object, then use the object’s accessor methods to retrieve it and display it on the screen. satak overfallowarrow_forwardProduct & Book Classes Programming the Product class USING the Product class Method to create an object of type Product if it has private attributes description, quantity, price from modProduct import * Assume that an object of type Product has already been created: myProduct = Product("Book",10,5.50) Write Python statements to: Method to retrieve the private member for the price: 1. PRINT the description Method to change the private member for the quantity: 2. CHANGE the price to 20.59 Method to convert an object of type Product to a string with labels and values. 3. PRINT the total spent Method to calculate the total spent on each product.arrow_forward
- What's the difference between a class's static and non-static data members? Give an example of why a static data member might be helpful in the real world.arrow_forwardThe properties of a child class are inherited by the parent class. Select one: True Falsearrow_forwardWrite the first line of the definition for a Poodle class. The class should be derived from the Dog class.arrow_forward
- EBK JAVA PROGRAMMINGComputer ScienceISBN:9781337671385Author:FARRELLPublisher:CENGAGE LEARNING - CONSIGNMENTC++ Programming: From Problem Analysis to Program...Computer ScienceISBN:9781337102087Author:D. S. MalikPublisher:Cengage LearningMicrosoft Visual C#Computer ScienceISBN:9781337102100Author:Joyce, Farrell.Publisher:Cengage Learning,
- Programming Logic & Design ComprehensiveComputer ScienceISBN:9781337669405Author:FARRELLPublisher:CengageC++ for Engineers and ScientistsComputer ScienceISBN:9781133187844Author:Bronson, Gary J.Publisher:Course Technology Ptr