Extend the functionality of cout by implementing a friend function in Number.cpp that overloads the insertion operator. The overloaded 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:

Answers

Answer 1

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.


Related Questions

What is a boot sector

Answers

Explanation:

A boot sector is the sector of a persistent data storage device which contains machine code to be loaded into random-access memory and then executed by a computer system's built-in firmware. Usually, the very first sector of the hard disk is the boot sector, regardless of sector size and partitioning flavor.

A five-year prospective cohort study has just been completed. the study was designed to assess the association between supplemental vitamin a exposure and mortality and morbidity for measles. the rr for incidence of measles was 0.75 and the rr for measles mortality was 0.5. Assume these RR are significant. Regarding the RR reported above, which statement is correct?

a. Exposure to vitamin A appears to protect against morbidity and mortality for measles.
b. Exposure to vitamin A appears to be a risk factor for morbidity and mortality for measles.
c. Exposure to vitamin A is not associated with morbidity and mortality for measles.
d. Exposure to vitamin A is a risk factor for morbidity and a protective factor for mortality for measles.

Answers

Answer:

Exposure to vitamin A appears to be a risk factor for morbidity and mortality for measles.

Explanation:

Select the statements that explain marking and categorizing messages. Check all that apply.


The Read/Unread option is a toggle button that marks a message read or unread.

You can mark a message as unread when you want to come back to it later.

You can mark a message as read by turning off the Categories option.

Categories are color coded and can be renamed and sorted.

Grouping different types of messages together can be done using Read/Unread.

answer: A B D

Answers

Answer:

The Read/Unread option is a toggle button that marks a message read or unread.

You can mark a message as unread when you want to come back to it later.

Categories are color coded and can be renamed and sorted.

Explanation:

Which view allows the user to see the source code and the visual representation simultaneously? to see the source code and the visual representation simultaneously? ​

Answers

Answer:

Split view.

Explanation:

HTML is an acronym for hypertext markup language and it is a standard programming language which is used for designing, developing and creating web pages.

Generally, all HTML documents are divided into two (2) main parts; body and head. The head contains information such as version of HTML, title of a page, metadata, link to custom favicons and CSS etc. The body of the HTML document contains the contents or informations of a web page to be displayed.

Split view allows the user to see the source code and the visual representation simultaneously.

It can be used in graphic design software such as Adobe Dreamweaver to get a side-by-side view of both the source code and code layout modules or design and source code.

For example, a user with a dual screen monitor can use the split view feature to display the design on monitor while using the other to display the source code.

Consider the following code segment, which is intended to simulate a random process. The code is intended to set the value of the variable event to exactly one of the values 1, 2, or 3, depending on the probability of an event occurring. The value of event should be set to 1 if the probability is 70 percent or less. The value of event should be set to 2 if the probability is greater than 70 percent but no more than 80 percent. The value of event should be set to 3 if the probability is greater than 80 percent. The variable randomNumber is used to simulate the probability of the event occurring.
int event = 0;
if (randomNumber <= 0.70)
{
event = 1;
}
if (randomNumber <= 0.80)
{
event = 2;
}
else
{
event = 3;
}
The code does not work as intended. Assume that the variable randomNumber has been properly declared and initialized. Which of the following initializations for randomNumber will demonstrate that the code segment will not work as intended?
A) randomNumber = 0.70;
B) randomNumber = 0.80;
C) randomNumber = 0.85;
D) randomNumber = 0.90;
E) randomNumber = 1.00;

Answers

Answer:

A) randomNumber = 0.70;

Explanation:

The code works perfectly for all values of randomNumber given in the options except option (a)

This is so because:

The first condition

if (randomNumber <= 0.70)  {  event = 1;  }

It checks if randomNumber is less than or equal to 0.70. This is true, so event is set to 1.

However, the next condition after it will also be executed because it is a different conditional to be executed.

So, we have:

if (randomNumber <= 0.80)  {  event = 2;  }

This condition is also true, so event is set to 2.

From the question randomNumber is meant to be event 1. However, this is different from the result of executing the code.

Hence, (a) is true

Type the correct answer in the box. Spell all words correctly.
After the filming is finished, Rachel is responsible for arranging individual shots in a proper sequence. Which role is she playing
Rachel as playing the role of a(n)

Answers

Answer:

editor

Explanation:

I just took the test and got it right.

How do you guys feel about McCree’s new look in Overwatch 2? I personally like it but some people have a distaste towards it. I personally think it’s a step in the right direction and improves on how he used to look.

Answers

Answer:

Agreed.

Explanation:

I also laugh that you put this on Brainly.

I agree

Explanation:

It's lit, very lit

Write a program that:

a. asks user to input the temperature in Fahrenheit.
b. It converts the inputted temperature into Celsius.
c. Calculates the speed of sound in meters per second and in feet per second. The program should display user's inputs and print the results in both m/s and ft/s

Answers

Answer:

sucks to suck

Explanation:

45. Our goals are a reflection of our:
O values
O standards
O obstacles
O resources
beliefs
values and beliefs

Answers

Values hope it helps you

Tech A states that modern vehicles use asbestos as the brake material. Tech B states that asbestos is no longer used in brakes. Who is correct?

Answers

Answer:

Tech A is correct.

Explanation:

The modern day vehicles have brakes system equipped with asbestos. It is a mineral which is a kind of fibrous crystal which enables the friction to stop the vehicle. The technician A specifies that the modern day automobiles use asbestos for their brake system.

Answer:

correct answer is Tech B.

Explanation:

just took the test

When adjusting the bounding box around text, hold the key to scale proportionately or the key to skew the object

Answers

Answer: ?

Explanation:

Directions: Identify the measuring devices and write its functions.
Write your answer in the space provided.

Answers

Answer:

1.weigher - to weigh meat

2.

3. scissor - to cut things

4. tongs

5.measuring cups - to measure dry ingredients like flour

6 temperature - measures temperature

7 measuring spoons

When designing code, which of the following best describes the purpose of a Post Mortem Review?

To obtain feedback on the code
To translate pseudocode to program code
To use code only one time
To check if others have the same code

Answers

Answer:

4

Explanation:

to check if others have the same code

what are layers in Photoshop ​

Answers

Answer:

Photoshop layers are like stacked pieces of stacked acetate. You can see through some parts because they are transparent. You can use layers to add on to your picture easily like adding extra images, text, or colors.

The image classification technology (Darknet) shown in the video is
free for anyone to use.
Select one:
a. proprietary
b. web-based
C. shareware
d. open source

Answers

Answer:

Open Source

Explanation:

Darknet is an open source custom neural network framework written in C and CUDA

Why is hydroelectricity counted as a conventional source of energy.. People say conventional sources of energy is the same as non-renewable energy sources

Answers

People have been using the energy of flowing or falling water for centuries before electricity was developed into a practical means of transporting energy. The first hydroelectric plant (at least in the U.S.) was built at Niagara Falls in 1895. Many areas of the world still get the majority of their power from hydro facilities.

Hydro is also “conventional” in the sense that it can be controlled in more or less the same way as thermal plants — its output can be adjusted over a wide range to match demand. Wind and solar, on the other hand, only produce when the wind blows or the sun shines. Of course, hydro can only produce as long as there’s rain or snowmelt to supply the reservoirs, but that’s on a much longer time scale; over hours or days, hydro capacity is very predictable.

How many digits are in the binary number system? Explain why.

Answers

Answer:

Since there are only two digits in binary, there are only two possible outcomes of each partial multiplication: If the digit in B is 0, the partial product is also 0. If the digit in B is 1, the partial product is equal to A.

Explanation:

Answer:

two digits

Explanation:

Binary – The binary numbering system has a base of 2 (MOD-2) and uses only two digits a “0” and a “1” to represent a binary number value.

Say you have 3 computers. Compare the cost of replacing the modem with a router/modem. Include the brand as well as price. I can't answer questions about this as I don't know what to do

Answers

Answer:

Comparing the cost of replacing the modem with a router/modem and its need in day today changing life.

Explanation:

As you known modem devices develop at a very gradual pace, you can normally use a modem for months, until it breakdown, but you might need to substitute a router because you require a more reachable area. After all, you've joined more computers to your web and your old router isn't holding up, or because you need to take the support of the latest development.

1) Who invented C Language.?
A) Charles Babbage
B) Grahambel
C) Dennis Ritchie
D) Steve Jobs​

Answers

Answer:

Dennis Ritchie is the answer

Write a program that uses while loops to perform the following steps:

a. prompt the user to input two integers: firstNum and secondNum
b. Output all odd numbers between firstNum and secondNum.
c. Output the sum of all even numbers between firstNum and secondNum.
d. Output the number and their squares between 1 and 10
e. Output the sum of the square of the odd numbers between firstNum and secondNum.
f. Output all uppercase letters.

Answers

Answer:

Explanation:

//Include the required header files.

#include<iostream>

using namespace std;

//Define the main function.

int main()

{

//Define the variables.

int i, sum = 0, sqSum = 0, firstNum = 1, secondNum = 0;

char ch;

//Check for valid input.

while (!(firstNum < secondNum))

{

cout << "Enter starting number: ";

cin >> firstNum;

cout<<"Enter ending number(must be > startingNumber): ";

cin >> secondNum;

}

//Store first number in i

i = firstNum;

//Dispaly the number.

cout << "The odd numbers between " << firstNum

<< " and " << secondNum << " are:\n";

//Iterate between first and second number.

while (i <= secondNum)

{

//Check for even numbers.

//Store the sum

if (i % 2 == 0)

sum = sum + i;

//Print the odd numbers

//Evaluate the square of sum of odd number.

else

{

cout << i << " ";

sqSum = sqSum + i * i;

}

//Increase the value of i.

i++;

}

//Dispaly the sum of even numbers.

cout << "\n\nThe sum of the even numbers is:"

<< sum << endl << endl;

//Dispaly the sum of square of odd number.

cout << "The sum of squares the odd numbers is:"

<< sqSum << endl;

//Set i to 1.

i = 1;

//Dispaly the message.

cout << "\nNumber Square\n";

//Iterate and print number between 1 andd 10

//along with the sum.

while (i <= 10)

{

cout << " " << i << "\t " << i * i << endl;

i++;

}

//USe for visual studio.

system("pause");

//Return the value 0.

return 0;

}

Explanation:

The program code will perform the function listed below using loop.

Prompt the user to input two integers: firstNum and secondNum (firstNum must be less than secondNum). Output all odd numbers between firstNum and secondNum. Output the sum of all even numbers between firstNum and secondNum. Output the numbers and their squares between 1 and 10. Separate the numbers using any amount of spaces. Output the sum of the square of the odd numbers between firstNum and secondNum. Output all uppercase letters.

Hope this helps!

What is the reddish-brown substance in the water?

Answers

Answer:

iron

Your water might be affected by iron, which is a commonly-occurring constituent of drinking water. Iron tends to add a rusty, reddish-brown (or sometimes yellow) color to water. If the color is more black than red, your water might contain a combination of iron and manganese.

the substance is iron in the water

does technology shape society or does society shape technology?

Answers

Answer:

Both. Society creates needs, these needs have to be met. Innovative people then meet the challenge because society says “we’ll compensate you if you can figure this out” and so the race begins. When that technology is developed, and the need is met, the technology inspires society to develop new wants and needs and so the cycle begins anew. Consider the biggest technologies in Human history: The wheel, created ancient civilization because it allowed for transport; The clock and calendar, allowing societies to develop schedules for all of their activities; Writing, allowing information to be passed down accurately from generation to generation; Farming, eliminating the need for civilization to be nomadic; Education systems, allowing for the standards of professionalism to be raised and specialized people to be created; fast-forward to the Industrial Age with the Steam Engine and Coal power plant; fast-forward again to the development of flight; fast-forward again to the atomic bomb and the first computer; etc.

Explanation:

The________ partitioning scheme enables you to create more than four primary partitions without needing to use dynamic disks

Answers

Answer:

three primary partitions

HELPOO ILL GIVE BRAINLIEST

Answers

Answer:

e

Explanation:

giv brainilest :D

While the Internet is used to share many useful services and information, there are growing concerns about the way that the Internet can be used to spread damaging information ranging from national secrets to calls for violence. Censoring this information may provide some people with increased security, but potentially risks free speech and the safety of social and political activists.

a. True
b. False

Answers

Answer:

A true!

Explanation:

Suppose we want an error correcting code that will allow all single-bit errors to be corrected for memory words of length 15. 1. How many check bits are necessary?2. Assuming we are using the Hamming algorithm presented to design our error-correcting code, find the code word to represent the 12-bit information word: 100100011010

Answers

Answer:

15

Explanation:

01234567891011121314

What are some study habits that you practice? Check all that apply.
studying with friends
studying on a regular schedule
taking breaks while studying
getting good sleep
studying in a quiet area

Answers

Answer:

studying in quiet place

Taking breaks

Reading from notes

good sleep

eating healthy foods

group study

studying on regular schedule

revision

Some study habits that you should practice are studying with friends, studying on a regular schedule, taking breaks while studying, getting good sleep, and studying in a quiet area. All options are correct.

What are good studying habits?

Effective study techniques can be used by someone who wants to get good scores. Summarizing, limiting distractions, taking breaks, and memorization are some good study techniques.

Several good study practices include: When studying, summarize your notes, avoid studying when you're sleepy, memorize your notes, limit distractions, and take breaks.

Study habit is an action such as reading, taking notes, holding study groups which the students perform regularly and habitually in order to accomplish the task of learning.

Therefore, the correct options are a, b, c, d, and e.

To learn more about studying habits, refer to the link:

https://brainly.com/question/14735769

#SPJ5

when computer network are joined together they form a bigger network called the​

Answers

Answer:

A WAN can be one large network or can consist of two or more lans connected together. The Internet is the world's largest wan.

Explanation:

Give 2 examples of how technology/AI has helped to achieve the SDGs.​

Answers

Answer:

Although AI-enabled technology can act as a catalyst to achieve the 2030 Agenda, it may also trigger inequalities that may act as inhibitors on SDGs 1, 4, and 5. This duality is reflected in target 1.1, as AI can help to identify areas of poverty and foster international action using satellite images5.

n is assisting immensely to serve all these needs. For example, digital e-health solutions such as 'mhealth' and remote diagnostics using telemedicine services have contributed significantly to improving access to healthcare facilities, reducing neonatal mortality, and providing better health coverage

20.

Meter is to Kilometer as Gigabyte is to

?

... PINGULAR

A. Byte

B. Terabyte

C. Kilobyte

O D. Pedabyte

E. Megabyte

Previous

Answers

Answer:

Megabyte

Explanation:

Megabytes come before Gigabytes like how Gigabytes come before Terrabytes

Other Questions
What disturbs the mirrors contemplation of the opposite wall? What does terrible fish symbolise? what is often in French? Simplify completely and find the restrictions on the variable. James is a lawyer who is representing a victim of domestic abuse in a casepresided over by Judge Danner. During an unofficial conversation in the hallway,James talks to Judge Danner about the woman's restraining order stating she moved into her parents home out of fear, but her parents' home is not on the list of addresses banned on the restraining order. Judge Danner decides to write the parents' address on a photocopy of the restraining order and authenticated the document without adding the new document to the court records.A. Ethical B. Unethical C. Illegal Your reasons: 1.2.3. please help me!!!!!! Read and choose the correct option.Daniel took a cruise to Costa Rica. One day, he spent six hours on a nature excursionon land. What did he most likely do at the end of the excursion to rest and relax?Sac el mapa.Us el sistema de posicionamiento global.Regres a bordo.Tom un metro. Find x and y . Leave the answers in radical form !! Help needed !! Evaluate: g(f(5))y = f(x)y = g(x) the slope is -3/2, the y intercept is 1. Write an equation for the linear function, f(x) recommend two ways in which women and children can be protected from discrimination and violence what is cell reference can someone help me with these three questions please?? Do you know what a pregnant woman should eat? Name at least five kinds of food that a pregnant woman should eat.Pag sinagutan moto edi congrats An individual that buys art is said to be a? What is the difference between a community and a population, and give one example of each? Pls, help me. If u can answer it I'll mark you as the brainiest. But I really need the example of each. Please help need done soon The residents of Watson Avenue are decorating their houses for the upcoming holidays. Theyhave decided to all string lights around the roofs of their houses. How many feet of lightingdoes Sarina need if she wants to string lights along roof?4 feet10 feet6 feet6 feet6 feet6 feet Plz explain how you solve this. What is the value of x in the equation?Two-thirds (x + 6) = negative 18363324Negative 18 Select the word from the drop-down menu that most accurately completes the sentence.The quality of Jasons new basketball was so ____ that it would not hold air for more than an hour and barely bounced when he tried to dribble.Choices for the blank:ImpressiveExtremeInferior Artificial what is 1 x 5555 + -6779 . 55555