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.

References:
C++ Templates by David Vandevoorde. Addison-Wesley, 2003.
http://cpptruths.blogspot.com/2005_06_01_archive.html

No comments:

Post a Comment