[Solved] How to pass object as parameter in function [closed]


You should know the concept of pass by value and pass by reference, e.g:

class A;
f(A& x);

using a ‘&’ sign to declare that here the parameter is using “itself”, not a copy.

more, if you are just using a parameter without changing any value of it. using const before parameter type.

e.g:

void f(const int& x) { x = 0; }

this cannot be compiled because of x cannot be assigned as a const parameter.

1

solved How to pass object as parameter in function [closed]