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

Popular posts from this blog

qt - switch/case statement in C++ with a QString type -

python - sqlite3.OperationalError: near "REFERENCES": syntax error - foreign key creating -

Python's equivalent for Ruby's define_method? -