Consider the below code. #include using namespace std; class Count { public: int count; }; Count(int c) { count C; } Count() { } count = 0; void increment (Count c, int times) { c.count++; times++; } int main() { } Count myCount; int times 0; - for (int i = 0; i < 100; i++) increment (myCount, times); cout << "myCount.count is << myCount. cout << times is << times; return 0; ** a. What is the printout of the above code? b. If the highlighted code above is changed to void increment(Count& c, int times) what will be the printout? . If the highlighted code above is changed to void increment(Count& c, int& times) what will be the printout? d. Can you change the highlighted code above to the following? void increment(const Count& c, int times)

icon
Related questions
Question
Consider the below code.
#include <iostream>
using namespace std;
class Count
{
public:
int count;
};
Count(int c)
{
}
}
count= c;
Count()
count = 0;
void increment (Count c, int times)
{
c.count++;
times++;
}
int main()
{
}
Count myCount;
int times= 0;
for (int i=0; i<100; i++)
increment (myCount, times);
cout << "myCount.count is " << myCount.count;
cout << times is " << times;
return 0;
a. What is the printout of the above code?
b. If the highlighted code above is changed to
void increment(Count& c, int times)
what will be the printout?
c. If the highlighted code above is changed to
void increment(Count& c, int& times)
RE
what will be the printout?
d. Can you change the highlighted code above to the following?
void increment(const Count& c, int times)
Transcribed Image Text:Consider the below code. #include <iostream> using namespace std; class Count { public: int count; }; Count(int c) { } } count= c; Count() count = 0; void increment (Count c, int times) { c.count++; times++; } int main() { } Count myCount; int times= 0; for (int i=0; i<100; i++) increment (myCount, times); cout << "myCount.count is " << myCount.count; cout << times is " << times; return 0; a. What is the printout of the above code? b. If the highlighted code above is changed to void increment(Count& c, int times) what will be the printout? c. If the highlighted code above is changed to void increment(Count& c, int& times) RE what will be the printout? d. Can you change the highlighted code above to the following? void increment(const Count& c, int times)
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 5 steps

Blurred answer
Similar questions