I was interested in one question. Where better to put the * when declaring a pointer to an object: class name or variable name?
The question is purely "philosophical". The most obvious answer is whatever you like. I asked around my colleagues I found out I put one * class name.
Decided to look into this matter. Turned to the original source
(Bjarne Stroustrup. The C programming language).
char * p; // pointer to symbol
That is generally a third option.
So decided to look in the standard
. About signs not specifically found was a piece of code where they are declared:
Tmp* p = new Tmp(a[i]*b[i]);
Before asking your opinion, I will Express their views and reflections. Everything that will be written next is just my opinion.The first variant
I myself use this, but I started to use it even before thinking about the meaning of at *. In this case the variable is considered as a variable of type "pointer to object type". Therefore a pointer is a separate type.The second variant
Well it's simple, it's just a pointer, that is, the number with the address where you can find the object of type type.
Actually a question: How do you declare pointers and is there a meaning or is it just a matter of habit?