Const declaration curiosity

233 views Asked by At

Ok, so i'm doing some exercise from a book, and I saw this declaration

float f, const c =9.9;

Initially, I thought this would be a compiler error, but I went into VS2013 and tested this, and it did not throw an error. I could even modify the c variable after declaration. I would like to know why and how is this possible,what is the compiler even doing with the const keyword in this case?

1

There are 1 answers

0
Shoe On BEST ANSWER

I would like to know why and how is this possible,what is the compiler even doing with the const keyword in this case?

It's not compiling it. Not with C++14, nor C++11, nor C++03, not even C.