Questions on c++

If you write a function that should use call-by-reference, but forget to include the ampersand, what will happen?

What is the value returned by the following function?
int function( )
{
int value = 35;
return value + 5;
value += 10;
}


What is the output of the following program fragment?
cout << pow(4,2) << endl;

appreciate any help, thanks
closed account (3hM2Nwbp)
1) Your compiler should throw an error message at you for not matching the formal prototype, or if both header and implementation are wrong, it depends on whether the types that are going to be copied are even copyable. If they aren't copyable, the compiler should yell at you again, but if they are copyable, they'll be copied.

2)
1
2
3
4
5
6
int function( )
{
    int value = 35;
    return value + 5;  // <-- Return 40
    value += 10;        // <-- Dead Code, never executed
}


3) 4^2=16
Last edited on
Topic archived. No new replies allowed.