Question: What (if anything) is different about the behavior of the following two functions f and g that increment a variable and print its value? void

What (if anything) is different about the behavior of the following two functions f and g that increment a variable and print its value?
void f(int x)
{ std::cout << ++x; } 

void g(int& x)
{ std::cout << ++x; }

Step by Step Solution

3.44 Rating (170 Votes )

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

In the function void fint x the value of the variable becomes the constant value passed while callin... View full answer

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Data Structures And Algorithms In C++ Questions!