-2

So I was reading a book about C++ (to be specific this book). A section of a page from the book:

The following statement declares the two variables lVariable1 and lVariable2 as type long int and sets them equal to the value 1, while dVariable is a >double set to the value 1.0. Notice in the declaration of lVariable2 that the int is assumed and can be left off:

// declare two long int variables and set them to 1
long int lVariable1
long lVariable2;
// int is assumed
lVariable1 = lVariable2 = 1;
// declare a variable of type double and set it to 1.0
double dVariable; dVariable = 1.0;

says that the "int is asummed and can be left off". What does this mean? Does it mean the variable

lVariable1

and the variable

lVariable2

is of the same type (and the same range)?

Also (sorry in advance to my stupidity) but of line 2 of the code above I noticed that it does not have a semicolon. I've tried to do it (copying and pasting the code above into an IDE and compiling it) but it's not valid. I believe that this is just a typo but I'm asking here just to make sure.

Thank you in advance.

1 Answers1

2

Yes, that is exactly what it means. Just like "short" and "short int" are the same. It's actually more complicated in that "int long" is also legal and the same.

SoronelHaetir
  • 14,104
  • 1
  • 12
  • 23