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

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

    Only use initialize function if you don't have the data available at point of creation.

    For example, you're dynamically building a model of data, and the data that determines the object hierarchy must be consumed before the data that describes object parameters.

    0 讨论(0)
提交回复
热议问题