I read a lot ebooks about C++. There are 2 way to declare a pointer, I don't know we should use which way although they are similar? And give me a reason.
Thanks.
I read a lot ebooks about C++. There are 2 way to declare a pointer, I don't know we should use which way although they are similar? And give me a reason.
Thanks.
There's also a third way: An it really doesn't matter which one you choose, as long as you use it consistently.
vql (4th February 2007)
I second jacek on this. This is a very small thing and consistency is what matters. I just want to point out that Qt used the second notation that is char *str;
Rationale:
Qt Code:
char* str1, str2; // here str1 is a char* and str2 is a char; char *str1, str2; // Here the declaration is more clear since the * is attached with the variableTo copy to clipboard, switch view to plain text mode
and FYI Qt uses the char *str; notation
We can't solve problems by using the same kind of thinking we used when we created them
It really doesn't matter The parser regognizes non-alphanumeric characters as token boundaries, so you may put as much spaces or other characters there. These all are valid as well:
It is all just about source code readability.
Exactly !!Originally Posted by wysota
The point is that char *str1, str2 seems to be more clear ( to me ). That is it. And I found this practice in Qt Sources.
We can't solve problems by using the same kind of thinking we used when we created them
Bookmarks