There is an other.
int * p;
Here is an otter
:)
Having an asterisk both be the type indicator and the dereference operator is one of the great programming language design blunders of our time, along with allowing nulls for any type in so many languages.
I also sometimes wish that the syntax in
if
statements was inverted, where()
was optional and{}
was required.Can you give me an example? I’m not sure I follow. Might be language specific?
if(condition) statement; Is valid in typical C-style syntax.
if condition { … }
Is invalid in typical C-style syntax
std::shared_ptr<int> p;
The fact it’s a pointer is part of the type, not part of the variable name. So
int* p
is the way.You would think so, but
int* a, b
is actually eqivalent toint* a; int b
, so the asterisk actually does go with the name. Writingint* a, *b
is inconsistent, soint *a, *b
is the way to go.