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:
long i;
};
Member Variable | Access Specification in Third Class |
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++ from Control Structures to Objects (9th Edition)
Additional Engineering Textbook Solutions
Database Concepts (7th Edition)
Modern Database Management
Introduction to Java Programming and Data Structures, Comprehensive Version (11th Edition)
Programming in C
Java: An Introduction to Problem Solving and Programming (8th Edition)
- Consider a base class Employee which contain basic information of an employee such as:Name(string)Address(string)Id(int)Gender(string)Now create two constructors A default constructor to initialize the data member with default values, A four-argument constructor to initialize data field with user-define values ( must use this key word). Getter and setter function to set and get values of data fields.Derives two classes to show Hierarchical inheritance.A department class which extends the base class employee also have some its own information such as:Department Name(string)Department Id(int).Now create two constructors a default constructor to initialize the data member with default values, a parameterized constructor to initialize data field with user-define values. Appropriate getter and setter function to set and get values of data fields. A display method to show all the records of employee along with department information.Create another child class Loan which extends the base…arrow_forwardPerson and Customer Classes Write a class named (Person) with data attributes for a person’s name, address, and telephone number. Provide accessors/getters and mutators/setters for each attribute. Write a displayPerson() to print out the attributes of the Person. Next, write a class named (Customer) that is a subclass of the (Person) class. The (Customer) class should have a data attribute for a customer number, and a Boolean data attribute indicating whether the customer wishes to be on a mailing list. Provide accessors/getters and mutators/setters for each attribute. Write a display customer() to print out the attributes of the Customer. Demonstrate an instance of the (Customer) class in a simple program.arrow_forwardDraw a class diagram consisting of a base class named Person and a derived class named Student consist of : Encapsulation Polymorphism Inheritance Base classes vs Derived classes Protected Access vs Packaged Access & Abstract Methods and Classesarrow_forward
- Generalization is a type of class relationship. What do know about Generalization, and arrange following classes in Generalization relationship using proper UML notation? Table, Chair, StudyTable, Bed, SingleBed, CoffeeTable, OfficeChair, RestChair, DoubleBed, Furniturearrow_forwardA class Student has Roll No, Branch, class Internal_exam has sub1marks, sub2 marks, class External_exam has sub1marks and class Result has Total as data members. Write necessary member functions to input and print data. (i) Calculate Internal_exam and External_exam subtotals using their respective member functions.(ii) Class Result has a function to calculate Total=internal+ external subtotals. Write a complete program to implement the hierarchy of the classes using virtual base class.arrow_forwardOverview Construct a hierarchy of classes representing savings and checking accounts as well as a means to ‘filter’ account objects. Account Classes Your solution will consist of 4 account classes as described below. It is your responsibility to define the exact relationship among those classes and translate that relationship into source code structure. There is a correct structure; the skeleton must be modified to reflect the correct relationships. Account – represents a general account with basic operations such as deposit, withdraw, etc. Savings – represents a savings account that must maintain a minimum balance. Checking – represents a checking account that has no minimum balance (this means a zero balance). CappedChecking – represents a checking account that disallows a balance above a particular maximum value. Linking Accounts A bank or credit typically allows a user the ability to link accounts together. That is, I might wish to link my checking account with my savings…arrow_forward
- Example 10-10 defined a class personType to store the name of a person. The member functions that we included merely print the name and set the name of a person. Redefine the class personType so that, in addition to what the existing class does, you can: Set the first name only. Set the last name only. Store and set the middle name. Check whether a given first name is the same as the first name of this person. Check whether a given last name is the same as the last name of this person.arrow_forward1.Write java classes to hold Account, SB-Account and Current-Account details. [Here implement the concept of inheritance.] The common properties of the account are Account number, name and amount. Specifics of SB account is 4% interest to be paid per month. Implement the run time polymorphism by creating base class variable and derived class object. Ask the user for which type of account to be created then create the corresponding account (Note: Use scanner class). Implement function overriding by having deposit and withdraw functions and perform the required action accordingly. Ensure base class can’t be instantiated. (Note: Abstract keyword can be used). 2.Define the minimum balance for the both the type of accounts. Use final keyword to create constants. Ensure sb account class and current account class will cannot be used as base classes (Note: You can use final classes).arrow_forward1. Draw the class diagram for superclass and subclass 2. Write a program using the following hints in Superclass. a) Declare the field years with its suitable data types and assign that field to the age. b) Create an accessor method to return the years.arrow_forward
- Consider a base class Employeewhich contain basic information of an employee such as: Name(string) Address(string) Id(int) Gender(string) Now create two constructors A default constructor to initialize the data member with default values, A four-argument constructor to initialize data field with user-define values ( must use this key word). Getter and setter function to set and get values of data fields. Derives two classes to show Hierarchical inheritance. A departmentclass which extends the base class employee also have some its own information such as: Department Name(string) Department Id(int). Now create two constructors a default constructor to initialize the data member with default values, a parameterized constructorto initialize data field with user-define values. Appropriate getter and setter function to set and get values of data fields. A display method to show all the records of employee along with department information. Create another child class Loanwhich extends the…arrow_forwardWrite classes to hold Account, SB-Account and Current-Account details. [Here implement the concept of inheritance.]The common properties of the account are Account number, name and amount.Specifics of SB account is 4% interest to be paid per month. Implement the run-time polymorphism by creating base class variable and derived class object. Ask the user for which type of account to be created then create the corresponding account (Note: Use scanner class). Implement function overriding by having deposit and withdraw functions and perform the required action accordingly.Ensure base class can’t be instantiated. (Note: Abstract keyword can be used).arrow_forward(Java) Make the 2 following classes: Employee.java EmployeeTest.java Copy and paste the below starter code into Employee.java: /** * Employee.java extends Person.java * @author * CIS 36B, Activity 11.1 */public class Employee extends Person { private static int numEmployees = 0; private double salary; private String title; /** * Default constructor for the * Employee class. Calls the * default constructor of the * superclass and also initializes * salary and title to default * values */ public Employee() { } /** * Multi-argument constructor for the * Employee class. Calls the * multi-argument constructor of the * superclass and also initializes * salary and title to the * specified values */ public Employee(String name, int age, String gender, Address a, double salary, String title) { } /** * Returns the annual salary * @return the salary */ public double…arrow_forward
- C++ 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:Cengage
- EBK JAVA PROGRAMMINGComputer ScienceISBN:9781337671385Author:FARRELLPublisher:CENGAGE LEARNING - CONSIGNMENTC++ for Engineers and ScientistsComputer ScienceISBN:9781133187844Author:Bronson, Gary J.Publisher:Course Technology Ptr