# 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.

## 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;
}
Published on 16-Feb-2018 11:38:55