Why is it thought of 'T *name' to be the C way and 'T* name' to be the C++ way?

Viewed 828

Note: This question is about the position of the asterisk (*).

In most C code I see (e.g., in Beej's guide to network programming), all variable declarations / definitions use the T *name format, i.e., bind the * to the variable name. The pointer is thought of belonging to the variable, not the type.

In most C++ code I see, the format is T* name, i.e., it binds the * to the type of the variable . The pointer is thought of belonging to the type, not the variable. I myself, as a pure C++ coder, also use this format, as a pointer-to-type clearly (for me) belongs to the type, not the variable. (Incidently, even the C++ standard uses this format in the examples. :) )

Is there a (historic) reason for this? Has the way of thinking just changed when programmers started doing C++?

It would also be nice if a C coder (that uses the former format) could explain on why s/he uses it, and not the latter.

10 Answers
Related