Object as function parameter: – We have three ways to pass the object as actual argument to the formal argument of object type of function definition.
- Call by value
- Call by address
- Call by reference
Call by Value: – An actual object will be passed as separate copy (Not master copy) to the formal argument. Any changes made with formal argument, the actual argument will not be affected.
Call by address: – In this technique, address of object as actual argument will be passed to the formal argument of pointer type object.
Any changes made with formal argument will also change the actual argument.
Call by reference: – In this technique we pass actual object as actual argument to the formal argument of reference type object. In this technique formal argument has same address as of actual argument so any changes made with formal argument will also change the actual argument permanently.