O'Reilly logo

Sams Teach Yourself C++ in 24 Hours, Third Edition by Jesse Liberty

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Q&A

Q1:If a short int can run out of room, why not always use long integers?
A1: Both short integers and long integers will run out of room, but a long integer will do so with a much larger number. However, on most machines a long integer takes up twice as much memory every time you declare one. Frankly, this is less of a problem than it used to be, because most personal computers now come with many thousands (if not millions) of bytes of memory.
Q2:What happens if I assign a number with a decimal to an integer rather than a float? Consider the following line of code:
int aNumber = 5.4;
A2: A good compiler will issue a warning, but the assignment is completely legal. The number you've assigned will be truncated into an integer. Thus, if you ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required