Jun 11, 2020 in C Plus Plus

When to use “const” reference arguments in a function?

1 Answer

0 votes
Jun 11, 2020
Using “const” reference arguments in a function is beneficial in several ways:

“const” protects from programming errors that could alter data.

As a result of using “const”, the function is able to process both const and non-const actual arguments, which is not possible when “const” is not used.

Using a const reference will allow the function to generate and use a temporary variable in an appropriate manner.

Structure & User-Defined Data Types
Click here to read more about Loan/Mortgage
Click here to read more about Insurance

Related questions