Declarations With Implicit int Aren’t Permitted

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.


About Our Editorial Process

At DevX, we’re dedicated to tech entrepreneurship. Our team closely follows industry shifts, new products, AI breakthroughs, technology trends, and funding announcements. Articles undergo thorough editing to ensure accuracy and clarity, reflecting DevX’s style and supporting entrepreneurs in the tech sphere.

See our full editorial policy.

About Our Journalist