Cảm ơn Microsoft dành cho Intellisense và Atomineer cho Utine Atomineer ... Tất cả các tham số này là bắt buộc và không thay đổi.Cải tiến trên một hàm tạo 13 tham số
Có cách nào tốt hơn để thực hiện việc này không?
/**************************************************************************************************
* <summary>Initializes a new instance of the ADTBattleCharacter class.</summary>
* <param name="name"> The name of the character.</param>
* <param name="max_HP"> The maximum hit points.</param>
* <param name="max_MP"> The maximum magic power.</param>
* <param name="strength"> The strength.</param>
* <param name="agility"> The agility.</param>
* <param name="attack_power"> The attack power.</param>
* <param name="defense_power">The defense power.</param>
* <param name="gold"> The gold carried by the character.</param>
* <param name="experience"> The experience the character is worth.</param>
* <param name="stop_resist"> The character's resistance to stopspell.</param>
* <param name="sleep_resist"> The character's resistance to sleep.</param>
* <param name="hurt_resist"> The character's resistance to hurt/hurtmore.</param>
* <param name="spell_list"> Available spells.</param>
**************************************************************************************************/
ADTBattleCharacter(std::string name, unsigned char max_HP, unsigned char max_MP,
unsigned char strength, unsigned char agility,
unsigned char attack_power, unsigned char defense_power,
unsigned short gold, unsigned short experience,
double stop_resist, double sleep_resist, double hurt_resist,
std::bitset<SPELL_MAX> spell_list);
Bạn không thể đóng gói tất cả vào một số đối tượng chứa và vượt qua thay vào đó? –
Đặt em vào một cấu trúc, đưa ra các giá trị mặc định hoặc căn cứ vào một số khác, thay đổi cái bạn cần và chuyển cấu trúc vào? – chris
@chris, mà chỉ punts vấn đề để các nhà xây dựng của cấu trúc. Không thực sự thay đổi bất cứ điều gì. –