Recently, I have started learning C++ and following the first book from this StackOverflow resource. My question is pretty straight forward. The way *
(in an expression) is defined as in the three current resources I am referring to learn C++ are as follows.
*
in this context is the dereference operator.
- C++ Primer says
*
yields an object. - Wikipedia says
*
returns an l-value equivalent to the value at the pointer address. - A Tour of C++ says
*
returns the content of object.
Where, 2
and 3
make complete sense to me but not 1
. Can someone dumb it down for me?
In my understanding an object is simply a memory location which holds some value.
However, Can object be thrown as keyword to reflect the value in context to dereferencing a pointer as in 1
?
Examples are greatly appreciated.
Edit: Solved, Answers by user eerorika
and bolov
are perfect and elegant. However eerorika
answered first so I will accept it as the answer but all the answers are great as well in their own way. Thanks SO community.