C++ / Programming

The C++ pointer

So, this is an interesting topic. Again, about craftsmanship. While most c++ if not all using them, it seems that some basic knowledge is lacking; This time, I’ll touche some basic facts: the const pointer.

Do you know the difference between the next two statements(#22 and #24)?

One won’t compile, one will work just fine.
The thing with const pointers? You need to know where they are.
while const Test2* ptest2

means a pointer to a const, Test2* const ptest22 means a const pointer to a none const value.
In the second case, any value pointed by ptest22 can be changed.

Leave a Reply

Your email address will not be published. Required fields are marked *