class - c++ declaring a variable when passing it into a function -


I have come from the world of C # which is doing something like it is allowed. When I try in C ++, I do not get any compiler errors, but I'm not sure it's actually working.

So more experienced people are allowed to do this:

  unit-> gt; Setpozzi (vector 2 (200, 400));   

As Vector 2 has a square and the condition of the set requires a vector parameter? Is this permission or I need to pre-start the variable like this:

  vector 2 aquacare (200, 400); Entity-> SetPosition (aVector); Thanksgiving   Vector 2 (200, 400));   

OK (and better) If you have defined SetPosition as one of the following: < Pre> zero set (vector 2 constant and v); // OK: const reference zero setPosition (vector 2V); // OK: value

is such, accepting the setposition argument as const context , Or just as value .

This will not work though:

  Zero Setposi (vector 2 and v); // is not ok: non-constitutional reference   

-

In C +11, you can write it (provided you have vector 2 to) :

  unit-> setposition ({200, 400});   

Thanks for @Simon to indicate this.

Comments

Popular posts from this blog

Python SQLAlchemy:AttributeError: Neither 'Column' object nor 'Comparator' object has an attribute 'schema' -

java - How not to audit a join table and related entities using Hibernate Envers? -

mongodb - CakePHP paginator ignoring order, but only for certain values -