Starting Out with C++: Early Objects (9th Edition)
9th Edition
ISBN: 9780134400242
Author: Tony Gaddis, Judy Walters, Godfrey Muganda
Publisher: PEARSON
expand_more
expand_more
format_list_bulleted
Concept explainers
Expert Solution & Answer
Chapter 15, Problem 8RQE
Program Description Answer
“Type cast” is required for the base class to be assign it to a derived class pointer.
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
Casting a base-class pointer to a derived-class pointer is called_______________
Operator______________ can be used to downcast base-class pointers safely.
Activity 1
This program firstly initializes an object of struct Cirele with values and then updates those
using pointers. The program uses structure notation once and pointer notation another
afterwards.
#include
#include
#define MIN 1
#define MAX 30
struct Circle {
float xCoord;
float yCoord;
float radius;
};
/* prototypes */
float getRandomNumber (int min, int max);
void printByValue(struct Circle cirobj);
void setValue(float *target, float newValue);
void printByReference(struct Circle *cirObj);
int main(void) {
/* Declare a struct circle and name it circleobject */
struct Circle circleObject;
/* Fill circleObject's members with random numbers */
circleobject.xCoord = getRandomNumber(MIN, MAX);
circleobject.yCoord = getRandomNumber (MIN, MAX);
circleobject.radius = getRandomNumber (MIN, MAX);
/* Printing values of the circle by calling function print by value */
printByValue(circleobject);
/* update values of circle one by one */
setValue (&circleobject.xCoord, getRandomNumber(MIN,…
Chapter 15 Solutions
Starting Out with C++: Early Objects (9th 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...
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
- 5. pointers, structs and arrays Given the definition struct Animal { char * species; int age; }; and the following animals: 5 year old gorilla 11 year old giraffe 4 year old cobra 2 year old gnu 8 year old lion Give a description in word AND draw a picture for each of the following declarations. Be sure to include the complete data for the animals described above. a) struct Animal zoo[5]; b) struct Animal * zoo2[5]; c) struct Animal (* zoo3)[];arrow_forwardY3arrow_forwardin C++, for classes with pointer member variables, you should include the copy constructor and the ____________________ in the class.arrow_forward
- Fill-in-the-Blank To allow an array of structures or an array of objects to be initialized, the struct or class declaration should include a(n) _________.arrow_forwardLanguage=C++ Create an employee class. The member data should comprise an int for storing the employee number and a float for storing the employee’s compensation. Member functions should allow the user to enter this data and display it. Write a main() that allows the user to enter data for three employees and display it (Use Array of objects).arrow_forwardPointer and classImplement a class called Team as specified:data members:name - the name of the Team (defined as a dynamic variable)members - a dynamic array of stringsize - number of members in the team.functions:Course(): default constructor set name to “TBD”, and size to 0, members toempty listCourse(string): one argument constructor set name, and size to 0, members toempty listaccessor - an accessor for the name and size variablemutator - an mutator for the name variableUse following main() to test your class.int main() {Team a,b("Mets");cout<<a.getName()<<endl; // print TBDa.setName("Yankee");cout<<a.getName()<<endl; // print Yankeecout<<b.getName()<<endl; // print Metscout<<a.getSize()<<endl; // print 0return 0;}arrow_forward
- An object’s non-static member functions have access to a “self pointer” to the objectcalled the_______________- pointer.arrow_forwardExplain how pointer work with classes and structs.arrow_forwardSmart Pointer: Write a smart pointer class. A smart pointer is a data type, usually implemented with templates, that simulates a pointer while also providing automatic garbage collection. It automatically counts the number of references to a SmartPointer<?> object and frees the object of type T when the reference count hits zero.arrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- Microsoft Visual C#Computer ScienceISBN:9781337102100Author:Joyce, Farrell.Publisher:Cengage Learning,C++ Programming: From Problem Analysis to Program...Computer ScienceISBN:9781337102087Author:D. S. MalikPublisher:Cengage LearningC++ for Engineers and ScientistsComputer ScienceISBN:9781133187844Author:Bronson, Gary J.Publisher:Course Technology Ptr
Microsoft Visual C#
Computer Science
ISBN:9781337102100
Author:Joyce, Farrell.
Publisher:Cengage Learning,
C++ Programming: From Problem Analysis to Program...
Computer Science
ISBN:9781337102087
Author:D. S. Malik
Publisher:Cengage Learning
C++ for Engineers and Scientists
Computer Science
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Course Technology Ptr