Problem Solving with C++ (9th Edition)
9th Edition
ISBN: 9780133591743
Author: Walter Savitch
Publisher: PEARSON
expand_more
expand_more
format_list_bulleted
Concept explainers
Textbook Question
Chapter 15.3, Problem 14STE
Suppose the base class and the derived class each have a member function with the same signature. When you have a pointer to a base class object and call a function member through the pointer, discuss what determines which function is actually called—the base class member function or the derived-class function.
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
Suppose the base class and the derived class each have a member function with the same signature. When you have a pointer to a base class object and call a function member through the pointer, discuss what determines which function is actually called—the base class member function or the derived-class function.
Given this class specification:
Class: Student
Data members: int ID
Write these function definitions:
1. An external definition of a member function that can be a const member function.
2. An external definition for a member function that should not be a const member function.
If a derived class redefines a member function inherited from the base class, for example a printInfo function, the derived class can call the base class's version of the function but it needs to use what operator to do so?
Chapter 15 Solutions
Problem Solving with C++ (9th Edition)
Ch. 15.1 - Is the following program legal (assuming...Ch. 15.1 - Prob. 2STECh. 15.1 - Is the following a legal definition of the member...Ch. 15.1 - The class SalariedEmployee inherits both of the...Ch. 15.1 - Give a definition for a class TitledEmployee that...Ch. 15.1 - Give the definitions of the constructors for the...Ch. 15.2 - You know that an overloaded assignment operator...Ch. 15.2 - Suppose Child is a class derived from the class...Ch. 15.2 - Give the definitions for the member function...Ch. 15.2 - Define a class called PartFilledArrayWMax that is...
Ch. 15.3 - Prob. 11STECh. 15.3 - Why cant we assign a base class object to a...Ch. 15.3 - What is the problem with the (legal) assignment of...Ch. 15.3 - Suppose the base class and the derived class each...Ch. 15 - Write a program that uses the class...Ch. 15 - Listed below are definitions of two classes that...Ch. 15 - Solution to Programming Project 15.1 Give the...Ch. 15 - Create a base class called Vehicle that has the...Ch. 15 - Define a Car class that is derived from the...Ch. 15 - Prob. 4PPCh. 15 - Consider a graphics system that has classes for...Ch. 15 - Flesh out Programming Project 5. Give new...Ch. 15 - Banks have many different types of accounts, often...Ch. 15 - Radio Frequency IDentification (RFID) chips are...Ch. 15 - The goal for this Programming Project is to create...Ch. 15 - Solution to Programming Project 15.10 Listed below...Ch. 15 - The computer player in Programming Project 10 does...Ch. 15 - Prob. 12PP
Additional Engineering Textbook Solutions
Find more solutions based on key concepts
It has been suggested that the control software for a radiation therapy machine, used to treat patients with ca...
Software Engineering (10th Edition)
True or False: A class may not have more than one constructor.
Starting Out with Java: From Control Structures through Objects (6th Edition)
Explain what can be done with primary keys to eliminate key ripple effects as a database evolves.
Modern Database Management
If a file already exists, what happens to it if you try to open it as an output file (using the w mode)?
Starting Out with Python (3rd Edition)
Give an example of a data constraint.
Database Concepts (7th Edition)
Describe a method that can be used to gather a piece of data such as the users age.
Web Development and Design Foundations with HTML5 (8th Edition)
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
- Assume the definition of class foodType as given in Exercise 6. Answer the following questions? (1, 2, 3, 5, 6) Write the definition of the member function set so that private members are set according to the parameters. The values of the int and double instance variables must be nonnegative. Write the definition of the member function print that prints the values of the data members. Write the definitions of the member functions getName, getcalories, getFat, getSugar, getCarbohydrate, getPotassium to return the values of the instance variable. Write the definition of the default constructor of the class foodType so that the private member variables are initialized to 0, 0. 0, 0, 0. 0, 0. 0, respectively. Write the definition of the constructor with parameters of the class foodType so that the private member variables are initialized according to the parameters. The values of the int and double instance variables must be nonnegative. Write a C + + statement that prints the value of the object fruit 2. Write a C++ statement that declares an object my Fruit of type foodType, and initializes the member variables of myFruit to Apple, 52, 0. 2, 10,13.8, and 148.0, respectively.arrow_forwardBoth child class and its parent class have same function signature. Which version of function will be called by the object pointer of parent class that is pointing to the child class’s object? Explain the reason. When do we need to use virtual function? Explain with example programarrow_forwardProgramming language C++ Call the virtual function for an object of each of the derived class. Now call it for the object of the base class.arrow_forward
- The distinction between a class's static and non-static data members is as follows: Give an example of real-world application where you think a static data member would be useful.arrow_forwardOne use of the this pointer is to access a data member when there is a local variable with the same name. For example, if a member function has a local variable x and a data member x, then you can refer to the data member as this->x. Use this fact to complete the constructor implementation of this Point class: class Point { public: Point(int x, int y); int get_x() const; int get_y() const; private: int x; int y; }; Not all lines are useful.arrow_forwardC++arrow_forward
- Once a function is declared as virtual, it remains virtual for the next derived class only if there is a virtual declaration in the derived class.arrow_forwardUsing C++ programming language in object oriented programming in C++ concept Create a class called time that has separate int member data for hours, minutes, and seconds.One constructor should initialize this data to 0, and another should initialize it to fixedvalues. Another member function should display it, in 11:59:59 format. The final member function should add two objects of type time passed as arguments.arrow_forwardQ2: Write a program that has an abstract base class. This class should have four member data variables and a pure virtual function. It should also have a method for setting the data variables. Derive a class from Base class and override a method in the base class. Write a main function that creates an object of derived class and sets the variables. Also write a top-level function that will take a parameter of type base class and return the value of the appropriate (override) function. LANGUAGE: C++arrow_forward
- C++ programming languagearrow_forwardThe difference between a static data member and a non-static data member of a class is as follows: In the real world, describe a situation in which a static data member might be beneficial.arrow_forwardC++ The class clockType was designed to implement the time of day in a program. Certain applications, in addition to hours, minutes, and seconds, might require you to store the time zone. Derive the class extClockType from the class clockType by adding a member variable to store the time zone called timeZone. Add the necessary member functions and constructors to make the class functional. Also, write the definitions of the member functions and the constructors. Finally, write a test program to test your class. Header file //clockType.h, the specification file for the class clockType #ifndef H_ClockType #define H_ClockType class clockType { public: void setTime(int hours, int minutes, int seconds); //Function to set the time. //The time is set according to the parameters. //Postcondition: hr = hours; min = minutes; // sec = seconds // The function checks whether the values of // hours, minutes, and seconds are…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
Introduction to Classes and Objects - Part 1 (Data Structures & Algorithms #3); Author: CS Dojo;https://www.youtube.com/watch?v=8yjkWGRlUmY;License: Standard YouTube License, CC-BY