5 ms·
I find that problem goes away if you only declare a single variable per line. Generally, I find people who do int* foo; Started with C++ and people who do
by scott_s 16y ago
I find that problem goes away if you only declare a single variable per line. Generally, I find people who do
int* foo;
Started with C++ and people who do
int *foo;
Started with C. I started with C++.
- dkersten 16y agoI have made the same observation and as someone who started with C++, I think it makes more sense that int* i; is an int pointer named i. int *i; just looks strange.. an int named pointer i umm? Besides, declaring only one variable per line seems less cluttered to me, so I never get the int* a, b; confusion.
- rbonvall 16y agoWhen used in an expression, I read p as "what's pointed by p". In a declaration, this applies as well: int *i; means "what's pointed by i is an int".
- dkersten 16y agoThat makes more sense alright, but I still think it would make a lot more sense if * was bound to the type.
- prodigal_erik 16y agoI never put the asterisk next to the type, because I wanted to train myself the way the grammar actually works rather than the way almost everyone wished it worked.
- scott_s 16y agoBut the compiler recognizes the type of the variable as int*.