Computer Science, asked by Samirsaini6013, 11 months ago

What is the most significant advantage that you see in using references instead of pointers

Answers

Answered by krish904
1

Answer:

Reference variables are the alias of another variable while pointer variable are the special type of variable that contains the address of another variable.

Reference and pointers both can be used to refer the actual variable they provide the direct access to the variable.

But, references have some advantages over the pointer variables, those are:

In pointers - To access the value of actual variable, we need to explicitly deference the pointer variable by using ‘value at address’ operator/ dereferencing operator (*).

In references - To access the value of actual variable, we do not need to explicitly dereference the reference variable, they gets de-referenced automatically.

Reference variables are cleaner and modish as compare to the pointers; they can also be used while passing in the function as arguments, known as call by references.

Similar questions