I am studying pointers in C + + and in my book there is a paragraph that explains what values can take a pointer
1) it can point to an object
2) it can just point to the location immediately past the end of an object
3) it can be a null pointer
4) it can be invalid
can you explain me point 2 ? what does it mean ? can you make me an example?
my book say :
two pointers are null if :
1) they are both null
2) they address the same object
3) or if they are both pointers one past the same object??
can you explain me point 3 ?
when will i need to use pointers again ? for now i'm just using them to change the value of an object......
Pointers have to be able to point the the location right past an object for a few reasons. One classic example is an array of 0 elements. A pointer of such array would always point to one past the last element, because there are no elements.
In C++, it's used a lot for denoting range of objects. Having a pointer point to one space past the object allows code to check against that pointer to see if it is still within the object or if it has reached the end.
I do not understand those last three questions. Maybe if you provide an exact quote instead of your own paraphrasing it might be more clear.
When will I need to use pointers again?
When you want to pass around the address of an object instead of the object itself. Or when you need to create something on the heap. In modern code, you should rarely be using raw pointers, but instead be using smart pointers. As you get more experience, you will understand their importance.