+91 90691 39140 | +1 253 214 3115 | info@hub4tech.com | hub4tech

C++ References Interview Questions and Answers

Difference between pass by value and pass by reference

In pass by value approach, the called function creates another copies of the variables passes as arguments. In this approach, the values of the original variables remain unchanged. However, we come across situations where we need to change the values of the original variables. Then the values may b passed by reference.

What is the difference between pointer and reference?

When a reference is created, it can’t reference another object. This can be done with pointers. References cannot be null whereas pointers can be. References cannot be uninitialized and it is not possible to refer directly to a reference object after it is defined.

What means 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.

What are References in C++? What is a local reference?

A restricted type of pointer in C++ is known as a reference. A reference can be assigned only once and can not have a null value.

A reference which has a local scope i.e., in a method or in a block or in a function is known as local reference.

What means 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.

Copyright ©2015 Hub4Tech.com, All Rights Reserved. Hub4Tech™ is registered trademark of Hub4tech Portal Services Pvt. Ltd.
All trademarks and logos appearing on this website are the property of their respective owners.