What is difference between int and const int& in C/C++?

C++Server Side ProgrammingProgramming

Here we will see what are the differences between int and const_int& in C or C++.

The int is basically the type of integer type data. And const is used to make something constant. If there is int& constant, then it indicates that this will hold the reference of some int type data. This reference value is constant itself. So the const is redundant. The compiler may return warning or some error.

The const int& is same as int const&. So this refers to a constant integer. The integer cannot be modified through the reference.

Published on 30-Apr-2019 15:24:28