Does it matter where I place the asterisk when declaring pointers in C++? -
I'm just learning C ++ and with the code of all the examples I have seen in the last few days that I understand the hard times Where the indicator should be kept.
What is the difference between these 3?
1 four * x = / * ... * / 2. four * y = / * ... * / 3. four * z = / * ... * / or
1 ClassX * x = / * ... * / 2. Class Y * y = / * ... * / 3. Classes * Z = / * ... * / Thanks for your help.
There is no difference they are exactly the same. You can choose to write it, however you wish. Typically, C ++ programmers place asterisks next to type , while C programmer is more common to star next to the name of variable . To be aware of only one misunderstanding, when you declare a number of multiple variables on a line (which you should not really do, if properly, not for). For example, in the following statement, only the variable x is declared as an indicator: char * x, y; Compare it with the following, which makes it more evident that there are extreme signs: char * x, y; The best I can say, the third syntax emerged as a bad deal between two major options. Rather than keeping a star next to one or the other, someone decided to keep it in the middle, which is the only place that definitely not relates.
Comments
Post a Comment