What are different types of constants in C++?

C++Object Oriented ProgrammingProgramming

There are no types of constants in C++. It's just that you can declare any data type in C++ to be a constant. If a variable is declared as constant using the const keyword, you cannot reassign its value. 


using namespace std;
int main() {
   const int i = 5;
   // Now all of these operations are illegal and
   // will cause an error:
   i = 10;
   i *= 2;
   return 0;
Updated on 11-Feb-2020 08:09:49