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

后端 未结 13 1523
孤独总比滥情好
孤独总比滥情好 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 14:54

    While I agree with the downsides of doing initialization exclusively in the constructor, I do think that those are actually signs of bad design.

    A deriving class should not need to override base class initialization behaviour entirely. This is a design flaw which should be cured, rather than introducing Initialize()-functions as a workaround.

提交回复
热议问题