Type Declaration - Pointer Asterisk Position

Posted by sahs on Stack Overflow See other posts from Stack Overflow or by sahs
Published on 2010-04-24T10:56:33Z Indexed on 2010/04/24 11:03 UTC
Read the original article Hit count: 237

Filed under:
|
|

Hello, in C++, the following means "allocate memory for an int pointer":

int* number;

So, the asterisk is part of the variable type; without it, that would mean something else (that's why I usually don't separate the asterisk from the variable type). Then what is the reason the asterisk is considered something else, instead of being part of the type? For example, it seems better, if the following meant "allocate memory for two int pointers":

int* number1, number2;

Am I wrong?

© Stack Overflow or respective owner

Related posts about c++

Related posts about pointer