Can I use default arguments in a constructor like this maybe
Soldier(int entyID, int hlth = 100, int exp = 10, string nme) : entityID(entyID = globalID++), hea
Only trailing arguments can be default arguments. You would need to give nme
a default argument or change the order of the arguments that the constructor takes so that hlth
and exp
come last.
As regards the assignment you make in the initialiser list what happens there is that the member entityID
gets assigned the value that is returned by the assignment of globalID++
to entyID
which will be the value of entyID
after the assignment. A similar thing happens for name
.