Advertisement
RobertDeMilo

RB3.10 Константный указатель и указатель на константу

Apr 16th, 2024
33
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.39 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. int main()
  6. {
  7.     int x = 5;
  8.     int* px = &x;
  9.     const int* cpx = &x;
  10.     int* const pxc = &x;
  11.     const int* const cpxc = &x;
  12.  
  13.     *px = 1;
  14.     ++px;
  15.  
  16.     //*cpx = 1; //нельзя
  17.     //++cpx;
  18.  
  19.     //*pxc = 1;
  20.     //++pxc;   //нельзя
  21.  
  22.     //*cpxc = 1; //нельзя
  23.     //++cpxc;    //нельзя
  24.  
  25.     return 0;
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement