Never Call Virtual Functions During Construction or Destruction

Today I have another Scott Meyers article for your enjoyment: "Never Call Virtual Functions During Construction or Destruction". The best summary I can offer comes from the master himself: I'll begin with the recap: you shouldn't call virtual functions during construction or destruction, because the calls won't do what you think, and if they did, …

Migrating from C to C++: NULL vs nullptr

On my last project, my team started working on implementing object-oriented concepts in C. Eventually we realized that we were reimplementing multiple C++ features. We admitted to ourselves that we would not implement our constructs more efficiently than the C++ compiler. We were also very interested in the extra safety mechanisms implicit in C++: better …

std::shared_ptr and shared_from_this

When introduced to the std::shared_ptr, many people immediately want to produce a function that returns a std::shared_ptr to this. //BAD! creates multiple control blocks to the same pointer std::shared_ptr<Thingy> get_a_thingy() { return this; } When the function above is used to generate a std::shared_ptr, each call will create a new control block. The first std::shared_ptr …