Well, I do not understand your for loop condition:
last = a + n;
edit:
oh now I can see, there is a comma there. Well, first of all - your for loop syntax is bad, which mislead me. Secondly, I know that is the case in C++(wish it was like in your 2nd post) - but declaring pointers like that is just bad, imho. It is error-prone, and most of the time, when you create pointers, you either use them instantly, or set them to nullptr. So I guess from all these examples, the best practice would be:
1 2
|
int* x = nullptr;
int *y = nullptr;
|
instead of
|
int *x = nullptr, *y = nullptr;
|
Second one is more ugly. If you like to look at these things, try this:
http://www.programmerinterview.com/index.php/c-cplusplus/c-declarations/
:)
And in your example, defining first as
int *first
wouldn't change anything. If someone is unable to see what type is he using, then it's something wrong with him, not his syntax.
And again, if he allocates some memory using operator new, he didn't make a mistake of using wrong syntax with * - as it doesn't matter at this point - but he made a mistake later:
new PlayerClass[nPlayers];
Here we can see an array of PlayerClass. If he used
new PlayerClass*[nPlayers];
that would be it.
And now I would like you to notice, that here he is using the same syntax as I talked about - with asterisk next to name, rather than variable.
And last of all:
You can declare functions using only types(and provide their names in definition), like this:
void someFunct(int*, int*&, char**&);
1 2 3 4 5 6
|
//code...
void someFunct(int* name1, int*& name2, char**& name3)
{
//code...
}
|
Because type is int*, not int. I think, that using your convention can be distracting for newbies. Also, when they got compiler error, they may wonder about what that type is, as compiler is using "my" method.
PS.
But of course it's all in purpose of simplifying code reading, and one may find any of these easier.