+ 2
Anyone explain me something....
I just created two programs of friend function see below,in c++ course they told that we have to pass object by reference.When i pass it by value its output is same?Explain. "https://code.sololearn.com/coJxRfvk7HgY/?ref=app" "https://code.sololearn.com/c21xPuhNAVA4/?ref=app"
1 Réponse
+ 2
pass by reference - giving you the power to change his values.
pass by value - creating totally new object, which you accessed him.
when you using 'friend' on some class it doesn't mean you always have to pass by reference to access his values.