default arguments in constructor

后端 未结 5 2024
失恋的感觉
失恋的感觉 2021-01-15 16:52

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

5条回答
  •  难免孤独
    2021-01-15 17:22

    All of the parameters with default arguments need to be after any required arguments. You should move the nme parameter before hlth.

提交回复
热议问题