Explain passing objects by reference, passing objects by value and passing objects by pointer

Explain passing objects by reference, passing objects by value and passing objects by pointer.

Pass by value :
The callee function receives a set of values that are to be received by the parameters. All these copies of values have local scope, i.e., they can be accessed only by the callee function. The simplicity and guarantee of unchanging of values passed are the advantages of pass by value.

Pass by reference :
The callee function receives a set of references which are aliases to variables. If a change is made to the reference variable, the original value (passed by the caller function) will also be changed. All the references are handled by the pointers. Multiple values modification can be done by passing multiple variables.

Pass by pointer :
The callee function receives a pointer to the variable. The value of the pointer in the caller function can then be modified. The advantages of this process are that the changes are passed back to the caller function and multiple variables can be changed.
Concepts of throwing and catching exceptions - C++
Explain the concepts of throwing and catching exceptions - C++ provides a mechanism to handle exceptions which occurs at runtime...
What are the advantages of “throw.....catch” in C++?
What are the advantages of “throw.....catch” in C++? - Code isolation: All code that is to be handled when an exception raises is placed....
What are friend classes? What are advantages of using friend classes?
What are friend classes? - The friend function is a ‘non member function’ of a class.....
Post your comment