can member functions be used to initialize member variables in an initialization list?

后端 未结 2 2084
借酒劲吻你
借酒劲吻你 2020-12-05 00:37

OK, member variables can be used to initialize other member variables in an initialization list (with care taken about the initialization order etc). What about member funct

2条回答
  •  被撕碎了的回忆
    2020-12-05 00:40

    While initializing objects in the initialization list, the object is not yet fully constructed.
    If those function tries to access the part of the object which is not yet constructed then that is a undefined behavior else its fine.
    see this answer.

提交回复
热议问题