3

C/C++ considers pointers to be declared next to the variable name rather than the type name (int *x, *y vs int* x, y).

I know this but I still consider * to be more associated with the type. Therefore I'm one of those people who declare each variable in its own line and group the type and * together. (int* x; int* y)

Comments
  • 0
    I always considered it the opposite of you. I read it as "x is a pointer of type integer": int *x
  • 1
    @killdashnine what would you expect a hypothetical typeof(x) operator to return? int or int*?
  • 0
    That in your vs example second y is int not int* implies you are doing it wrong! If I inherit your code, I would curse like a tinker and refactor the shit!
  • 0
    @danzig666 I know that. Perhaps read my comment properly? That's why variables are declared on individual lines each.
  • 0
    @tumtumtum I did! Still would refactor 😳
Add Comment