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

typedef

It can become tedious, repetitious, and, most important, error-prone to keep writing unsigned short int. You can create a synonym for an existing type by using the keyword typedef, which stands for type definition.

It is important to distinguish this from creating a new type (which you will do in Hour 7, “Basic Classes”). typedef is used by writing the keyword typedef followed by the existing type and then the new name. For example,

typedef unsigned short int USHORT

creates the new name USHORT that you can use anywhere you might have written unsigned short int. Listing 3.3 is a replay of Listing 3.2 using the type definition USHORT rather ...

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