How to create simple immutable int in C++? I have a function:
int NOD(const int &a, const int &b) {
if (b == 0) {return a;}
const int remainder = a % b;
return NOD(b, remainder);
}
which supposed to take two ints and returns greatest common divisor. But I didn't find a way to make a and b immutable, hence they can be altered within function, for example if we add a line in function:
*(int *)&a = 555;
it breaks everything. How to make immutable variables in C++?