Declarations With Implicit int Aren’t Permitted

Does your compiler accept the following declarations?

  volatile x; const y  = 0; 

In pre-standard C++, the default type in such incomplete declarations was int. Thus, the first declaration would declare x as “volatile int” and y as “const int. ” However, according to the C++ standard, declarations with implicit int aren’t permitted anymore. Instead, you have to specify the variable’s type explicitly:

  volatile int x; // OK const int y  = 0; // OK

Many compilers aren’t yet compliant in this respect and accept the incomplete declarations given above. You shouldn’t count on this because future versions of your compiler will probably flag such declarations as errors.

Share the Post:
Share on facebook
Share on twitter
Share on linkedin

Overview

Recent Articles: