Starting Out with C++: Early Objects Plus MyLab Programming with Pearson eText -- Access Card Package (9th Edition)
Starting Out with C++: Early Objects Plus MyLab Programming with Pearson eText -- Access Card Package (9th Edition)
9th Edition
ISBN: 9780134520520
Author: Tony Gaddis, Judy Walters, Godfrey Muganda
Publisher: PEARSON
bartleby

Concept explainers

bartleby

Videos

Textbook Question
Book Icon
Chapter 15.3, Problem 15.3CP

What will the following program display?

#include <iostream>

#include <memory>

using namespace std;

class First

{

protected:

int a;

public:

First(int x = 1) { a = x; }

int getVal() const { return a; }

};

class Second : public First

{

private:

int b;

public:

Second(int y = 5) { b = y; }

int getVal() const { return b; }

};

int main()

{

Shared_ptr<First> object1 = make_shared<First>();

shared_ptr<Second> object2 = make_shared<Second>():

cout << object1->getVal() << endl;

cout << object2−>getVal() << endl:

return 0;

}

Blurred answer
Students have asked these similar questions
write a program in c++ ,Create a class called Complex for performing arithmetic with complex numbers.Write a program to test your class. Complex numbers have the form   Real Part + imaginary Part * i where i is Use double variables to represent the private data of the class. Provide a constructor that enablesan object of this class to be initialized when it’s declared. The constructor should contain default values in case no initializers are provided. Provide public member functions that perform the following tasks: 1-Printing Complex numbers in the form (a, b), where a is the real part and b is the imaginarypart. 2-Adding two Complex numbers: The real parts are added together and the imaginary parts are added together. 3-Subtracting two Complex numbers: The real part of the right operand is subtracted from the real part of the left operand, and the imaginary part of the right operand is subtracted from the imaginary part of the left operand.   note:notice to solve point 1,you solve…
Hello, I am having trouble with this homework question for my c++ course.   Implement a Rational Number class with the following specifications. Data members a) numerator and denominator Functions a) Constructors: 1) default constructor 2) single parameter constructor to create numerator/1 3) dual parameter constructor to create numerator/denominator 4) Use constructor delegation across all constructors. b) Accessors and Mutators for both data members. c) Static recursive GCD function using Euclid's algorithm. d) Static LCM function for two numbers. e) Reduce function simplify a rational number. This function modifies its calling object. f) Your program should work with the supplied driver program.   Notes LCM (Least Common Multiple) This function returns the smallest multiple of a and b. Step 1: Multiply a and b to find a common multiple. Step 2: Divide the common multiple by the GCD of a and b. Step 3: Return the result of Step 2. Reduce: This function reduces a fraction to…
Reuse your Car class . In a main, build an object of that class, and print out the object using System.out.println(). Notice that this simply reports the memory address of the object in question, and we’d like to do something more useful. To replace (or override) the toString (or equals) function. Now, build a toString function that prints out the make, model, and odometer reading for a vehicle object. public class Car {    //instance variables    private int odometer;    private String make;    private String model;        //overloading    //constructors    public Car(int odometer,String make, String model) {        this.odometer = odometer;        this.make = make;        this.model = model;    }    public Car(String make, String model) {        this.make = make;        this.model = model;    }        public Car(String make) {        this.make = make;    }        /*     *getter & setter methods     */    public int getOdometer() {        return odometer;    }     public void…

Chapter 15 Solutions

Starting Out with C++: Early Objects Plus MyLab Programming with Pearson eText -- Access Card Package (9th Edition)

Additional Engineering Textbook Solutions

Find more solutions based on key concepts
Knowledge Booster
Background pattern image
Computer Science
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
SEE MORE QUESTIONS
Recommended textbooks for you
Text book image
Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education
Text book image
Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
Text book image
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
Text book image
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
Text book image
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Text book image
Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education
What is Abstract Data Types(ADT) in Data Structures ? | with Example; Author: Simple Snippets;https://www.youtube.com/watch?v=n0e27Cpc88E;License: Standard YouTube License, CC-BY