1answer.
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]
3 years 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]3 years 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
How major is the technology problem in the United States?
babymother [125]

Answer:

The technology problems in the U.S are like

New security threats. Headline-grabbing recent events may spark surprising new security threats, says Rick Grinnell, founder and managing partner of Glasswing Ventures. ...

Data protection. ...

Skills gap. ...

Multi-cloud security. ...

Innovation and digital transformation. ...

Finding new revenue streams. ...

Lack of agility. ...

Outsourcing risks. danger

Explanation:

Hope this helped!!!

4 0
3 years ago
How can the Internet help our country to be a leader in technology?
BigorU [14]

Answer:

it can help in the aspect of making technologies to be fastly operated with fast internet connection there by it top among all other countries

4 0
3 years ago
Which of the following code segments will display all of the lines in the file object named infile, assuming that it has success
zimovet [89]

Answer:

d.

for line in infile :

   print(line)

Explanation:

for loop is used to iterate through the each line of the file using line variable. The file is accessed using the object infile. For example if the file name is "file.txt" and it is opened in read mode. It contains the following lines:

hi there friend

how are you

what are you doing

Then the above given chunk of code gives the following output

hi there friend

how are you

what are you doing

At each iteration each line of the the file is printed on the output screen. The print() method is used to display these lines in output.

5 0
3 years ago
Alcohol increases your ability to see at night. A. True B. False
Agata [3.3K]
False, alcohol does nothing to enhance your vision
8 0
4 years ago
Read 2 more answers
____ are programs that enable the browser to work with an embedded object.
DerKrebs [107]
HTML's to learn more go to https://developer.mozilla.org/en-US/docs/Web/HTML/Element/embed
5 0
4 years ago
Other questions:
  • True or false
    7·1 answer
  • DOES ANYONE KNOW HOW TO CHAGE THE IP ON A COMPUTER?
    8·1 answer
  • 1. An auto repair shop charges as follows. Inspecting the vehicle costs $75. If no work needs to be done,
    9·1 answer
  • What font is the declaration of independence?
    9·1 answer
  • What advantage does having ultraviolet vision give bees?
    10·2 answers
  • In printing systems using ____, a disk accepts output from several users and acts as a temporary storage area for all output unt
    14·1 answer
  • Refer to the following statement: “We have implemented several IT solutions:
    14·1 answer
  • A student should always read the directions to a test or question so they know what is expected of them when answering the quest
    9·2 answers
  • Write the following program: Use struct data type to store information about courses. Every course is characterized by the follo
    6·1 answer
  • Pleaseee helpppppppppp
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!