logoalt Hacker News

dako2117 • today at 7:12 PM • 1 reply • view on HN

I believe there are also cases where you have a member variable which has a complicated initialization that you may want to handle in some sort of manner that is not appropriate for the default ctor. So you may not want to initialize everything right away in this scenario.


Replies

spacechild1 • today at 7:44 PM

Can you give a concrete example? Why wouldn't you initialize the member to something, e.g. a sentinel value?

Note that if the member is non-trivial, its default constructor is called either way.