This question goes out to everyone who knows the latest c++ standard by heart:P.
We have the following program:
#include <iostream>
using namespace std;
void wow(int& x, int& y, int&z)
{
x=x+1;
y=z;
z=z+1;
}
int main()
{
int i=0;
int A[2]={10,11};
wow(i, A[i], i);
cout<<i<<endl;
cout<<A[0]<<endl;
cout<<A[1]<<endl;
}
So we have parameter passing by reference and in the function wow we give 2 times the same variable...
This was one of the questions they gave us in the exam of the course "Compilers and language principals..."
The gave us the above code...and told us to say what it will print if we had parameter passing
by reference,
call by value,
call by name,
call by value result...
The gave us the above code in pascal so i "translated it" in c++....{i know that c++ doesn't support all the possible parameter passing techniques}
Comments?
PS:: why the gave us the code in Pascal {pascal isn't in our curricula}...did pascal support all the above methods in parameter passing {or the gave us the code in pascal in order to look like pseudocode}?
PS2::if i compile the program i get an answer, but i am still asking if this is undefined behaviour because i read in the book Concepts.of.Programming.Languages.7th.Edition{0321330250- Addison.Wesley} that it is a no-no to give the same argument to function that utilizes parameter passing by reference....