// (C) Porkolab 2003 // // A.1.2. // When constants are allocate memory #include <iostream> int f(const int i) { // 5_const.cpp: In function `int f(int)': // 5_const.cpp:7: increment of read-only parameter `i' // ++i; return i; } int main() { const int c1 = 1; // no memory needed const int c2 = 2; // need memory const int c3 = f(3); // need memory const int *p = &c2; int t1[c1]; int t2[c2]; // 5_const.cpp: In function `int main()': // 5_const.cpp:19: warning: ISO C++ forbids variable-size array `t' // int t3[c3]; int i; std::cin >> i; switch(i) { case c1: std::cout << "c1"; break; case c2: std::cout << "c1"; break; // 5_const.cpp: In function `int main()': // 5_const.cpp:30: case label does not reduce to an integer constant // case c3: std::cout << "c1"; break; } return 0; }