answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Law Incorporation [45]
1 year ago
14

Extend the functionality of cout by implementing a friend function in Number.cpp that overloads the insertion operator. The over

loaded insertion operator returns an output stream containing a string representation of a Number object. The string should be in the format "The value is yourNum", where yourNum is the value of the integer instance field of the Number class.Hint: the declaration of the friend function is provided in Number.h.Ex: if the value of yourNum is 723, then the output is:
Computers and Technology
1 answer:
san4es73 [151]1 year ago
7 0

Answer:

// In the number.cpp file;

#include "Number.h"

#include <iostream>

using namespace std;

Number::Number(int number)

{

   num = number;

}

void Number::SetNum(int number)

{

   num = number;

}

int Number::GetNum()

{

   return num;

}

ostream &operator<<(ostream &out, const Number &n)

{

   out << "The value is " << n.num << endl;

   return out;

}

// in the main.cpp file;

#include "Number.cpp"

#include <iostream>

using namespace std;

int main()

{

   int input;

   cin >> input;

   Number num = Number(input);

   cout << num;  

   return 0;

}

Explanation:

The main function in the main.cpp file prompts the user for the integer value to be displayed. The Number file contains defined functions and methods of the number class to set, get and display the "num" variable.

You might be interested in
Survey Q. Non-scoring: If you are working in a customer facing agile team, who is more mature/ready for Agile? (1 correct answer
fomenos

I think that 3 would be the correct answer

8 0
2 years ago
Read 2 more answers
Write the printitem() method for the base class. sample output for below program: last name: smith first and last name: bill jon
ella [17]
The question involves basic polymorphism. The following is the partial flow of the program.

baseItemPtr = new BaseItem();
baseItemPtr.setLastName("Smith");

derivedItemPtr = new DerivedItem();
derivedItemPtr.setLastName("Jones");
derivedItemPtr.setFirstName("Bill");

itemList.add(baseItemPtr);
itemList.add(derivedItemPtr);

for (i = 0; i < itemList.size(); ++i) {
itemList.get(i).printItem();
}

return;
7 0
2 years ago
Read 2 more answers
What Information Technology is Walt Thomas responsible for?
adelina 88 [10]
Proactive designing i think
3 0
2 years ago
Read 2 more answers
Which of the following will you select as X in the following series of clicks to lay the title over a chart: Chart Title box &gt
guapka [62]

Answer:

A

Explanation:

We are to lay a title over a chart, which means the position of the title should be above the chart.

When doing this, it will centre the title over the chart without duly interfering with the original size of the chart.

The option 'over chart' is incorrect as it is not a valid selection in the pane. Below chart as well is incorrect as we are to lay the title above the chart.

3 0
2 years ago
A chess-playing computer program that routinely calculates all possible outcomes of all possible game moves best illustrates pro
Evgesh-ka [11]
<span>A chess-playing computer program that routinely calculates all possible outcomes of all possible game moves best illustrates problem solving by means of </span>brute force.
5 0
2 years ago
Other questions:
  • Suppose the algorithms used to implement the operations at layer k is changed. how does this impact services at layers k-1 and k
    10·1 answer
  • George and Miguel are considering opening up a shoe store but first need to do market research. Which one of these is NOT part o
    13·2 answers
  • Mellissa wants to pursue a career in database administration. Select the requirements needed to achieve this.
    9·2 answers
  • Need 2.5 Code Practice Answers
    14·2 answers
  • 1. Consider a client and a server connected through one router. Assume the router can start transmitting an incoming packet afte
    13·1 answer
  • A client is asking for a printing solution that will print three sheets of paper with identical information on each page with a
    13·1 answer
  • An encryption system works by shifting the binary value for a letter one place to the left. "A" then becomes: 1 1 0 0 0 0 1 0 Th
    12·1 answer
  • In this challenge, write a function to add two floating point numbers. Determine the integer floor of the sum. The floor is the
    8·1 answer
  • A credit card company receives numerous phone calls throughout the day from customers reporting fraud and billing disputes. Most
    10·1 answer
  • Laura is the first person in her SDLC team to detect and predict security vulnerabilities in the software. In which phase is Lau
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!