A reason to prefer the second one is when you declare multiple variables at once:
string *str, *foo;
string* str, foo;
Those two lines are different, the first one declares to pointers, whereas the second one declares one pointer to string
and one string
.
[Comment by FredOverflow] This problem can be solved by some template magic, though ;-)
template <typename T>
struct multiple
{
typedef T variables;
};
multiple<string*>::variables str, foo;