1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39
| #include <iostream> int main() { const int buffersize = 512; int a = 1; int b = 2; const int* p = &a; std::cout << "now p point to a: " << *p << std::endl; p = &b; std::cout << "now p point to b: " << *p << std::endl;
int const* p1 = &a; std::cout << "now p1 point to a: " << *p1 << std::endl; p1 = &b; std::cout << "now p point to b: " << *p1 << std::endl;
int* const p2 = &a; *p2 = b;
return 0; }
|