Tuesday, November 23, 2010

Type Decay

The following compiles:
int myArray[5] = {3};
const int (*s)[5] = &myArray;

'int myArray[5]' has a different type than 'int *myArray'. Sometimes the first type will be converted by the compiler to the second type. This conversion is sometimes called 'decay.' In this case 'decay' means loss of type information.

C++ Templates by David Vandevoorde. Addison-Wesley, 2003.

No comments:

Post a Comment