Junior — Senior
Determine the output of the program with a function reference
livecode
Task condition
It is necessary to understand what values will be printed when executing the following code.
#include <iostream>
int counter = 2;
int& refFunc(int x){
counter = counter + x;
return counter;
}
int main(){
int val = 2;
std::cout << refFunc(val) << std::endl;
refFunc(val) = 10;
std::cout << refFunc(val) << std::endl;
val = refFunc(val);
std::cout << refFunc(val) << std::endl;
}