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
Textbook Question
Chapter 11, Problem 27RQE
Assume a class named Length exists. Write the header for a member function that overloads the stream insertion << operator for that class.
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
Assume a class named Collection exists. Write the header for a member function that overloads the [] operator for that class.
Language=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).
// This program reads floating point data from a data file and places those // values into the private data member called values (a floating point array) // of the FloatList class. Those values are then printed to the screen.// The input is done by a member function called GetList. The output// is done by a member function called PrintList. The amount of data read in // is stored in the private data member called length. The member function// GetList is called first so that length can be initialized to zero.#include <iostream>#include <fstream>#include <iomanip>
using namespace std;const int MAX_LENGTH = 50; // MAX_LENGTH contains the maximum length of our list class FloatList // Declares a class that contains an array of// floating point numbers{ public:void getList(ifstream&); // Member function that gets data from a file void printList() const;// Member function that prints data from that // file to the screen.FloatList();// constructor that sets length to…
Chapter 11 Solutions
Starting Out with C++: Early Objects (9th Edition)
Ch. 11.3 - What is the difference between an instance member...Ch. 11.3 - Static member variables are declared inside the...Ch. 11.3 - Does a static member variable come into existence...Ch. 11.3 - What limitation does a static member function...Ch. 11.3 - What action is possible with a static member...Ch. 11.3 - If class X declares function f as a friend, does...Ch. 11.3 - Suppose that class Y is a friend of class X,...Ch. 11.5 - Briefly describe what is meant by memberwise...Ch. 11.5 - Prob. 11.9CPCh. 11.5 - Prob. 11.10CP
Ch. 11.5 - When is a copy constructor called?Ch. 11.5 - How does the compiler know that a member function...Ch. 11.5 - What action is performed by a classs default copy...Ch. 11.6 - Assume there is a class named Pet. Write the...Ch. 11.6 - Assume that dog and cat are instances of the Pet...Ch. 11.6 - What is the disadvantage of an overloaded ...Ch. 11.6 - Prob. 11.17CPCh. 11.6 - Prob. 11.18CPCh. 11.6 - Assume there is a class named Animal, which...Ch. 11.6 - Prob. 11.20CPCh. 11.6 - Describe the values that should he returned from...Ch. 11.6 - Prob. 11.22CPCh. 11.6 - What type of object should an overloaded operator...Ch. 11.6 - Prob. 11.24CPCh. 11.6 - If an overloaded or operator accesses a private...Ch. 11.6 - Prob. 11.26CPCh. 11.6 - When overloading a binary operator such as or as...Ch. 11.6 - Explain why overloaded prefix and postfix and ...Ch. 11.6 - Prob. 11.29CPCh. 11.6 - Overload the function call operator ( ) (int i,...Ch. 11.8 - Prob. 11.31CPCh. 11.8 - How is the type declaration of an r value...Ch. 11.8 - Prob. 11.33CPCh. 11.8 - Prob. 11.34CPCh. 11.8 - Which operator must be overloaded in a class...Ch. 11.8 - Prob. 11.36CPCh. 11.10 - What arc the benefits of having operator functions...Ch. 11.10 - Prob. 11.38CPCh. 11.10 - Assume that there is a class named BlackBox. Write...Ch. 11.10 - Assume there are two classes, Big and Smal1.Write...Ch. 11.13 - What type of relationship between classes is...Ch. 11.13 - Why does it make sense to think of a base class as...Ch. 11.13 - What is a base class access specification?Ch. 11.13 - Think of an example of two classes where one class...Ch. 11.13 - What is the difference between private members and...Ch. 11.13 - What is the difference between member access...Ch. 11.13 - Suppose a program has the following class...Ch. 11.14 - What is the reason that base class constructors...Ch. 11.14 - Why do you think the arguments to a base class...Ch. 11.14 - Passing arguments to base classes constructors...Ch. 11.14 - What will the following program display? #include...Ch. 11.14 - What will the following program display? #include...Ch. 11 - If a member variable is declared _____, all...Ch. 11 - Static member variables are defined _____ the...Ch. 11 - A(n) _____ member function cannot access any...Ch. 11 - A static member function may be called _____ any...Ch. 11 - A(n) _____ function is not a member of a class,...Ch. 11 - A(n) _____ tells the compiler that a specific...Ch. 11 - _____ is the default behavior when an object is...Ch. 11 - A(n) _____ is a special constructor, called...Ch. 11 - _____ is a special built-in pointer that is...Ch. 11 - An operator may be _____ to work with a specific...Ch. 11 - When the _____ operator is overloaded, its...Ch. 11 - Making an instance of one class a member of...Ch. 11 - Object composition is useful for creating a(n)...Ch. 11 - A constructor that takes a single parameter of a...Ch. 11 - The class Stuff has both a copy constructor and an...Ch. 11 - Explain the programming steps necessary to make a...Ch. 11 - Explain the programming steps necessary to make a...Ch. 11 - Consider the following class declaration: class...Ch. 11 - Describe the difference between making a class a...Ch. 11 - What is the purpose of a forward declaration of a...Ch. 11 - Explain why memberwise assignment can cause...Ch. 11 - Explain why a classs copy constructor is called...Ch. 11 - Explain why the parameter of a copy constructor...Ch. 11 - Assume a class named Bird exists. Write the header...Ch. 11 - Assume a class named Dollars exists. Write the...Ch. 11 - Assume a class named Yen exists. Write the header...Ch. 11 - Assume a class named Length exists. Write the...Ch. 11 - Assume a class named Collection exists. Write the...Ch. 11 - Explain why a programmer would want to overload...Ch. 11 - Each of the following class declarations has...Ch. 11 - A derived class inherits the _____ of its base...Ch. 11 - The base class named in the following line of code...Ch. 11 - The derived class named in the following line of...Ch. 11 - In the following line of code, the class access...Ch. 11 - In the following line of code, the class access...Ch. 11 - Protected members of a base class are like _____...Ch. 11 - Complete the following table by filling in...Ch. 11 - Complete the following table by filling in...Ch. 11 - Complete the following table by filling in...Ch. 11 - When both a base class and a derived class have...Ch. 11 - When both a base class and a derived class have...Ch. 11 - An overridden base class function may be called by...Ch. 11 - Each of the following class declarations and/or...Ch. 11 - Soft Skills 44. Your companys software is a market...Ch. 11 - Check Writing Design a class Numbers that can be...Ch. 11 - Day of the Year Assuming that a year has 365 days,...Ch. 11 - Day of the Year Modification Modify the DayOfYear...Ch. 11 - Number of Days Worked Design a class called...Ch. 11 - Palindrome Testing A palindrome is a string that...Ch. 11 - Prob. 6PCCh. 11 - Corporate Sales A corporation has six divisions,...Ch. 11 - Prob. 8PCCh. 11 - Rational Arithmetic II Modify the class Rational...Ch. 11 - HTML Table of Names and Scores Write a class whose...Ch. 11 - Prob. 11PC
Additional Engineering Textbook Solutions
Find more solutions based on key concepts
Use what youve learned about the binary numbering system in this chapter to convert the following decimal numbe...
Starting out with Visual C# (4th Edition)
The code that follows shows an example of branching on an enumerated type value in a switch statement. Recall t...
Computer Systems: A Programmer's Perspective (3rd Edition)
Write a fragment of code that will read words from the keyboard until the word done is entered. For each word e...
Java: An Introduction to Problem Solving and Programming (7th Edition)
Write a for loop that displays the following set of numbers: 0, 10, 20, 30, 40, 50 1000
Starting Out with Java: From Control Structures through Objects (7th Edition) (What's New in Computer Science)
This statement can cause other program statements to execute only under certain conditions. 1. Conditional 2. D...
Starting Out With Visual Basic (8th Edition)
List the classes (n2), (log2n), (n), and (n3) in decreasing order of efficiency.
Computer Science: An Overview (13th Edition) (What's New in Computer Science)
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
- c++Create a Stock class with member data: • code • name •value per unit • number of purchased units and member functions• constructors• get () and set () methods• input method () to enter a Stock object from the keyboard • method of calculating the amount to be paid for the goods • redefine the operation to compare two goods by id and the operation to insert into the streamarrow_forwardPROGRAMMING LANGUAGE: C++ Write a program which has a class named FileHandlerto read StudentName, MarksObtained from the attached picture. The class should have a function which calculates grade for a student and then adds it in a new column i.e. Grade. The grade should be calculated considering the following criteria. A: 87-100, B+: 80-86, B: 72-79, C+: 66-71, C: 60-65, D: 50-59, F: 0-49 The file should be saved once grade for all students is calculated. Write the driver program for executing the task.arrow_forwardC++ You may work on a single class. The parameter and return type s of each function and class member function should be decided in advance. The program will be best implemented as a multi-file program, (header file, the main program,..) Design a generic class to hold the following information about a bank account: Balance Number of deposits this month Number of withdrawals Annual Interest Rate Monthly service charges The class should have the following member function: Constructors Accepts arguments for the balance and annual interest rate. deposit a virtual function that accepts an argument for the amount of the deposit. The function should add the argument to the account balance. It should also increment the variable holding the number of deposits. withdraw a virtual function that accepts an argument for the amount of the withdrawal. The function should subtract the argument from the account balance. It should also increment the variable…arrow_forward
- For a non-constant member function of class Test, the this pointer has type: Select one: O a. const Test * const O b. Test * const O . Test const * O d. const Test *arrow_forwardTrue or false? Only instance member functions can be defined as constant functions.arrow_forwardC++ True/False: a member function in a class can access all of its class's member variables, but not if the variables are private.arrow_forward
- Variables defined inside a member function of a class have Select one: a. File scope b. Class or block scope, depending on whether the binary scope resolution operator (::) is used c. class scope d. Block scopearrow_forwardiin c++arrow_forward#include <iostream>using namespace std;class Box {double width;public:friend void printWidth( Box box ); //declare friendsvoid setWidth( double wid );};// Member function definitionvoid Box::setWidth( double wid ) {width = wid;}// Note: printWidth() is not a member function of any class.// it is written directly without Box::void printWidth( Box box ) {/* Because printWidth() is a friend of Box, it candirectly access any member of this class */cout << "Width of box : " << box.width <<endl;}// Main function for the programint main() {Box box;// set box width without member functionbox.setWidth(10.0);// Use friend function to print the wdith.// call directly that can access private variables of box.printWidth( box );return 0;} -By using above code To make points and length parameters of triangles and ellipses to be private. Make a counter for how many triangle-objects that are created. The counter is a static variable. - Display the areas and the counting values.…arrow_forward
- Write a remove member function that accepts an argument for a number of units and removes that number of units of an item from inventory. If the operation is completed successfully it should return the number of units remaining in stock for that item. However, if the number of units passed to the function is less than the number of units in stock, it should not make the removal and should return –1 as an error signal.arrow_forwardUsing c++ create a class with a static member item so that when ever a new object is created the total number of objects of the class can be reported.arrow_forwardTRUE OR FALSE: In C++, comments that begin with the "multi-line" comment symbol can't be nested. A member function of a class has access to only the public data members of the class. If a C++ function does not take any parameters, parenthesis around the empty parameter list are still required. The size of a pointer variable depends on the type that it is pointing to.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 LearningMicrosoft Visual C#Computer ScienceISBN:9781337102100Author:Joyce, Farrell.Publisher:Cengage Learning,
C++ Programming: From Problem Analysis to Program...
Computer Science
ISBN:9781337102087
Author:D. S. Malik
Publisher:Cengage Learning
Microsoft Visual C#
Computer Science
ISBN:9781337102100
Author:Joyce, Farrell.
Publisher:Cengage Learning,
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