How to read the construction of pointers in C ++?

This is a C ++ question for beginners. What is the difference between the two designs?

1. const int* const* const x 2. const int** 

How can I read these constructs?

+6
source share
3 answers

We understand that some people are upset by the decision this week. We are not going to share the details out of respect for all those involved, but this is a site that spans millions of people, and we must do what, in our opinion, fosters a spirit of inclusiveness and respect. When the moderator violates this, we always do our best to solve it privately with them. When we cannot, we must act. This is always done based on what we consider the best for all SE users.

+2
source

How can I read these constructs?

Read them back and read * as a "pointer to".

 const int* const* const 

is a constant pointer to a constant pointer to an integer constant.

 const int** 

is a pointer to a pointer to an integer constant.

+8
source

There is a useful / useful tool for decoding ads: http://cdecl.ridiculousfish.com/

In your case, it reports: const int* const* const x => declare x as const pointer to const pointer to const pointer int int const int** x = declare x as pointer to pointer to constant pointer int

+2
source

All Articles