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


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.

Updated on: 30-Jul-2019

3K+ Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements