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

Creating New Types

You've already learned about the C++ built-in types, including int (integers) and char (characters). The type of a variable tells you quite a bit about it. For example, if you declare Height and Width to be unsigned short integers, you know that each one can hold a number between 0 and 65,535 (assuming an unsigned short integer is 2 bytes).

In addition to telling you the size, the type tells you the capabilities of the variable. For example, short integers can be added together. Thus, just by declaring Height and Width to be unsigned short integers, you know that it is possible to add Height to Width and to assign that number to another number.

The type of these variables tells you

  • Their size in memory

  • What information they ...

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