Answer the question
In order to leave comments, you need to log in
How to define a class method so that the object is not passed to it by reference?
Let be
class MyClass
{
int x, y;
int sum1();
}
MyClass::sum1() { return x+y; }
MyClass MyVar;
MyVar.sum1();
int sum2(MyClass &MyVar) { return MyVar.x + MyVar.y }
MyClass MyVar;
sum2(MyClass &MyVar);
int sum2(MyClass MyVar) { return MyVar.x + MyVar.y }
MyClass MyVar;
sum2(MyClass MyVar);
Answer the question
In order to leave comments, you need to log in
UPD. Now I understand what you mean. It is not possible in this form.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question