DEV Community

Discussion on: C/C++ Pointer Alignment Style: A Justification

Collapse
stefanomontani profile image
stefanomontani

I'm a young c++ programmer and a veteran c# programmer and I have to say that the notation with the asterisk aligned to the left makes more sense to me. Alas, if writing “int* a, b, c” results in the declaration of the first variabile as a pointer to int and of the others two as int variables, from a logical point of view this closes the question for me: the right syntax requires to attach the asterisk to variable (it is no more a problem of alignment). Or the language is flawed (LOL). Bad form is one thing, another thing is wrong syntax.

Though, to follow my preferences and habits (and VC++ default formatting) I think I will use the asterisk aligned to the left and the pratice to write a separate declaration for any variabile.