What are different types of constants in C++?

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.

Example

#include<iostream>
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;
i++;
i--;
//...
return 0;
}
Lakshmi Srinivas

Programmer / Analyst / Technician