Should I use virtual 'Initialize()' functions to initialize an object of my class?

后端 未结 13 1525
孤独总比滥情好
孤独总比滥情好 2020-12-17 14:33

I\'m currently having a discussion with my teacher about class design and we came to the point of Initialize() functions, which he heavily promotes. Example:

13条回答
  •  醉酒成梦
    2020-12-17 15:12

    Forget about the Initialize() function - that is the job of the constructor.

    When an object is created, if the construction passed successfully (no exception thrown), the object should be fully initialized.

提交回复
热议问题