Hello!
I'm just trying to understand passing by value and passing by reference but while i was writting the code another question came up. If I try to print out the value like this: cout << passbyV(a); it gives me a mistake: "no match for 'operator<<' in std::cout << passbyV(a)". What is the reason for this mistake? I already have the correct code, i was trying to write my own. The correct code is: passbyV(a); passbyR(b); cout << a << endl; cout << b << endl;
Thank you in advance!
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
void passbyV(int x);
void passbyR(int *x);
int main(){
int a = 1;
int b = 1;
cout << passbyV(a) << endl;
passbyR(&b);
}
void passbyV(int x){
x = 50;
}
void passbyR(int *x){
*x = 30;
}