1.

Following are some incomplete declarations, what do each of them mean?

Answer»

1. const int X;2. int const x;3. const int *x;4. int * const x;5. int const * x const;

  • The first two declaration points 1 and 2 mean the same. It means that the variable x is a read-only constant integer.
  • The third declaration represents that the variable a is a pointer to a constant integer. The integer value can't be modified but the pointer can be modified to POINT to other locations.
  • The fourth declaration means that the variable x is a constant pointer to an integer value. It means that the integer value can be changed, but the pointer can't be MADE to point to ANYTHING else.
  • The last declaration means that the variable x is a constant pointer to a constant integer which means that neither the pointer can point to a different location nor the integer value can be modified.


Discussion

No Comment Found