my question is how do you know when to use the syntax CCdataType* varName = ...
, vs. CCdataType *pVarName = ...
I know that the second one is a pointer, but maybe I'm missing something... I don't understand the difference. is the first one a deference statement? do you use the pointer as in CCdataType *pVarName if the value you are referencing is out of the scope of the class that you are writing in?
... I know that the second one is a pointer ...
Both are pointers. Just that the "*" is shifted left and right.
CCdataType* varName = ...
is conventionally considered more C++
style. CCdataType *pVarName = ...
is more intuitive in
the situations where you are declaring several pointer members, such
as: T *p1, *p2, *p3;
.By the way, you can even write:
CCdataType*pVarName = ...
Here is the exact information to your question from Bjarne's FAQ page.