You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Oct 26, 2023. It is now read-only.
passByReference(&sandy); //Note that '&sandy' is done for passing by reference.
cout << "Betty: " << betty << endl;
cout << "Sandy: " << sandy << endl;
}
void passByValue(int x){
//Here while passing the variable from main() to this function, copies of the data of the variables are made and the original variable cannot be touched from this function
x = 99;
//The original variable is unmodified
}
void passByReference(int *x){ //*x will hold the Memory Address of the passed variable
//This way, by passing a variable by reference in a function, we have direct control of the variable inside the function