Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All
Important This document may not represent best practices for current development, links to downloads and other resources may no longer be valid. Current recommended version can be found here.

Standard Conversions

The C++ language defines conversions between its fundamental types. It also defines conversions for pointer, reference, and pointer-to-member derived types. These conversions are called "standard conversions." (For more information about types, standard types, and derived types, see Types.)

This section discusses the following standard conversions:

The following code causes conversions (in this example, integral promotions):

long  lnum1, lnum2;
int   inum;

// inum promoted to type long prior to assignment.
lnum1 = inum;

// inum promoted to type long prior to multiplication.
lnum2 = inum * lnum2;
NoteNote

The result of a conversion is an l-value only if it produces a reference type. For example, a user-defined conversion declared as

operator int&()
NoteNote

returns a reference and is an l-value. However, a conversion declared as

operator int()
NoteNote

returns an object and is not an l-value.

Community Additions

ADD
Show:
© 2015 Microsoft