Starting Out With C++: Early Objects (10th Edition)
10th Edition
ISBN: 9780135235003
Author: Tony Gaddis, Judy Walters, Godfrey Muganda
Publisher: PEARSON
expand_more
expand_more
format_list_bulleted
Textbook Question
Chapter 15, Problem 15RQE
C++ Language Elements
Suppose that the classes Dog and Cat derive from Animal, which in turn derives from Creature. Suppose further that pDog, pCat, pAnimal, and pCreature are pointers to the respective classes. Suppose that Animal and Creature are both abstract classes.
15. Will the statement
Animal a;
compile?
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
Object oriented c++
An abstract class
a. Cannot be used to declare pointers and references
b. Has at least one pure virtual function
c. Can be instantiated
d. Cannot have any constructors
help with c++
1. Name three concepts we must implement to demonstrate Polymorphism between two classes.2. What problem must we avoid when coding Polymorphism? 3. How do we avoid this problem?4. Code one of the following topics as a simple abstract class.MovieVideoGameCurrency5. Code a simple second class to demonstrate polymorphism and overriding.6. Instantiate an object of the second class to demonstrate polymorphism.
Chapter 15 Solutions
Starting Out With C++: Early Objects (10th Edition)
Ch. 15.3 - Prob. 15.1CPCh. 15.3 - Prob. 15.2CPCh. 15.3 - What will the following program display? #include...Ch. 15.3 - What will the following program display? #include...Ch. 15.3 - What will the following program display? #include...Ch. 15.3 - What will the following program display? #include...Ch. 15.3 - How can you tell from looking at a class...Ch. 15.3 - What makes an abstract class different from other...Ch. 15.3 - Examine the following classes. The table lists the...Ch. 15 - A class that cannot be instantiated is a(n) _____...
Ch. 15 - A member function of a class that is not...Ch. 15 - A class with at least one pure virtual member...Ch. 15 - In order to use dynamic binding, a member function...Ch. 15 - Static binding takes place at _____ time.Ch. 15 - Prob. 6RQECh. 15 - Prob. 7RQECh. 15 - Prob. 8RQECh. 15 - The is-a relation between classes is best...Ch. 15 - The has-a relation between classes is best...Ch. 15 - If every C1 class object can be used as a C2 class...Ch. 15 - A collection of abstract classes defining an...Ch. 15 - The keyword _____ prevents a virtual member...Ch. 15 - To have the compiler check that a virtual member...Ch. 15 - C++ Language Elements Suppose that the classes Dog...Ch. 15 - Will the statement pAnimal = new Cat; compile?Ch. 15 - Will the statement pCreature = new Dog ; compile?Ch. 15 - Will the statement pCat = new Animal; compile?Ch. 15 - Rewrite the following two statements to get them...Ch. 15 - Prob. 20RQECh. 15 - Find all errors in the following fragment of code,...Ch. 15 - Soft Skills 22. Suppose that you need to have a...Ch. 15 - Prob. 1PCCh. 15 - Prob. 2PCCh. 15 - Sequence Sum A sequence of integers such as 1, 3,...Ch. 15 - Prob. 4PCCh. 15 - File Filter A file filter reads an input file,...Ch. 15 - Prob. 6PCCh. 15 - Bumper Shapes Write a program that creates two...Ch. 15 - Bow Tie In Tying It All Together, we defined a...
Additional Engineering Textbook Solutions
Find more solutions based on key concepts
Under what circumstances should a member function be private?
Starting Out with C++ from Control Structures to Objects (9th Edition)
Write a Python statement that given an existing variable called bodyTemp in degrees Fahrenheit stores the equiv...
Computer Science: An Overview (12th Edition)
Give an example of a data constraint.
Database Concepts (7th Edition)
Define each of the following terms: entity type entity-relationship model entity instance Attribute relationshi...
Modern Database Management (12th Edition)
Repair Bill Suppose automobile repair customers are billed at the rate of per hour for labor. Also, suppose co...
Introduction To Programming Using Visual Basic (11th 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
- CS 232 - Lab #6 - Pets Ahoy! We have recently been discussing the creation of classes in C++. Recall that classes serve as a "template" for the objects in our program, and that when we instantiate a class, we are creating an object which models the properties and behaviors of real-world objects. For this assignment, design and implement a parent class to represent a pet and several small sub-classes of the most common pets for cats, dogs, birds, and turtles. Each pet object is characterized by a type, name, birth date, owner, weight, sex, speak, and color. The variable data type for the type variable is a string that identifies the type of pet as a "dog", "cat", "bird", "turtle". The name is a string that identifies the name of the pet. The owner variable is a string that designates the name of the pet's owner. The weight specifies the pet's weight in pounds and is a double value. The speak variable is a string that holds an onomatopoeia of the sound the animal makes when it “speaks”…arrow_forwardi need the c++ codearrow_forwardAccomplish the following for the given class diagram. Elevator 1. Create the class implementation using C++ upDirection 2. Create one object from class Elevator and store it in the stack memory. 3. Create one object from class Elevator and store it in the heap memory. 4. Test all the functions of the two objects • currentFloor: int • move (numFloors : int): void stop (): void + status (): stringarrow_forward
- Implement the following hierarchy using C++ classes. 1. Shape: This should be an interface class that supports area() and display() functions. 2. Circle and Rectangle: Implement the area and display functions of Shape. 3. Quadrilateral: This class should be an abstract class. It may contain member variables for length and height. 4. Trapezoid: Should inherit length, height from Quadrilateral, and add 'side', represents the side parallel to 'length'. 5. Create appropriate .h/.cpp files with constructors and destructors (wherever needed). which 6-arrow_forwardState a circumstance in which you would prefer an interface over an abstract class. Also, State a circumstance in which you would prefer an abstract class over an interface.arrow_forwardCall the virtual function for an object of each of the derived class. Now call it for the object of the base class. Subject: object oriented programming Language:C++arrow_forward
- Call the virtual function for an object of each of the derived class. Now call it for the object of the base class. Subject:object oriented programming Language:C++arrow_forwardUse Visual Studio C# Languagearrow_forwardWrite a c++ oop code following these instructions only. Class Scene: capture_date : int draw() : void // Abstract method Class Landscape: area : double render(): void Class FlightSimulator: It has aggregation relationship with abstract class Redefine draw() function that has only a print statement of “Drawing Scene”. Class MountainScene: Call render function of Landscape as mentioned in diagram. (a) Add a function getArea() in 'Scene' class. Class Scene: capture_date : int draw() : void // Abstract method getArea() : string // Displays 'Area of Scene' Class CityScene: draw() : void getArea() : string // Displays 'Area of City Scene' Class MountainScene: draw() : void getArea() : string // Displays 'Area of Mountain Scene' (b) 1- Create a pointer of Scene class 2- Assign object of MountainScene class to the pointer created in part 1 3- Call getArea() through the pointer 4- Report the output you get in part 3arrow_forward
- Declare classes Person and Student where Student is derived from Person class. Person has Name and Student has RollNo as its private member. Create a Student class object and initialize it with the already existing object of Student class. Analyze the behavior of default constructors of Person and Student classes. Note: use OOP Concepts with C++ language Solve as soon as possiblearrow_forwardWhat does an abstract class serve?arrow_forwardGame of Chess in C++ The objective of this assignment is to practice concepts related to inheritance, overriding, polymorphism, and abstract classes, to program the basics of a chess playing program. About: Chess is played on an 8 X 8 board where the initial placement of pieces. The white king is on e1, and the black king is on e8. Each chess piece can move in a specific way. Follow a simplified version. Most importantly, ignore an important rule in chess: Moving any piece in a way that puts your own king in check is illegal. Since we don't know what check means, for us a move is legal if the piece we are moving has an empty square to move to or can capture (replace) an opponent's piece (including their king). The king does not move at all. Nor can it castle the queen and knight can't move either. A pawn in the initial position may move one or two squares vertically forward to an empty square but cannot leap over any piece. Subsequently it can move only one square vertically forward…arrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- C++ for Engineers and ScientistsComputer ScienceISBN:9781133187844Author:Bronson, Gary J.Publisher:Course Technology PtrC++ Programming: From Problem Analysis to Program...Computer ScienceISBN:9781337102087Author:D. S. MalikPublisher:Cengage LearningProgramming Logic & Design ComprehensiveComputer ScienceISBN:9781337669405Author:FARRELLPublisher:Cengage
C++ for Engineers and Scientists
Computer Science
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Course Technology Ptr
C++ Programming: From Problem Analysis to Program...
Computer Science
ISBN:9781337102087
Author:D. S. Malik
Publisher:Cengage Learning
Programming Logic & Design Comprehensive
Computer Science
ISBN:9781337669405
Author:FARRELL
Publisher:Cengage
C++ Data Members; Author: CppNuts;https://www.youtube.com/watch?v=StlsYRNnWaE;License: Standard YouTube License, CC-BY