+ 2
Please explain me reference counting in easy language
2 odpowiedzi
0
No reference:
void function(bool x)
{
x = true;
}
int main()
{
bool reference = false;
function(reference); //&reference != &x
cout << reference; //false
}
Reference:
void function(bool& x)
{
x = true;
}
int main()
{
bool reference = false;
function(reference); //&reference == &x
cout << reference; //true
}
With a reference, function arguments are not copied.
Do you have questions about this?
0
nope