Quote:Original post by ricardo_ruiz_lopez
Quote:Original post by supamike
[...]
it doesn't matter so much, but i think 'type *identifier' is a good habit to have.
I disagree with you.
int is a type (integer)
int* is another type (a pointer to an integer)
what is "int space"? (or int * number)
I disagree with your disagreement :P
The language applies the * qualifier to the variable, not the type.
By pretending that int* is a type on its own, you create a model of your programming language in your mind that diverges from how things actually are.
Same goes for const. Will this compile?
const int *i = 0, *j = 0; j = i;
The answer is yes, because the type is not const int or const int *, but int. So i is const and j isn't.
If you instead read "int" as saying "the following variables are variants of the type int", it becomes clearer.
int *const i = 0, *const j = 0; j = i;
Of course you can decide to completely avoid multiple variable declarations in a single statement. In which case it is all a matter of personal preference.
I prefer to have the code look the way the language will interpret it as much as possible. Though I do wish that they had designed it the way you seem to want it with qualifiers belonging to the type instead of the variable.