Lessie if I can explain better: (or maybe just make it more confusing)
const int* type1; // non-const pointer to const int int* const type2; // const pointer to non-const int int value1 = 1 * 2; // 2 int value2 = 2 * 1; // also 2 typedef int* IntPtr; const IntPtr type3; // const pointer to non-const int IntPtr const type4; // ALSO const pointer to non-const int const int onePlusOne = 1 + 1; int value3 = onePlusOne * 2; // 4 int value4 = 2 * onePlusOne; // 4 #define INT_PTR int* const INT_PTR type5; // non-const pointer to const int! INT_PTR const type6; // const pointer to non-const int // of course if the * isn't there, suddenly const is commutative const int type7; // const int int const type8; // ALSO a const int
I'm still lost. Maybe I'm reading your example as compilable code and it's not? type1 - 8 are not used with value1 - 4, so I'm lost on the math issue. How does const int vs. int const change the way the compiler calculates the mathematical expressions?