Pergunta de entrevista da empresa Weta Digital

What should not be in a constructor?

Respostas da entrevista

Sigiloso

1 de set. de 2015

I answered several things that should not be in, apparently the answer should have been any virtual functions.

Sigiloso

26 de fev. de 2017

Hmm, the first answer that came to mind was: two new statements, without a try-catch around the second that deletes the first. There are probably many answers to such a vague question; it is indeed unintuitive to programmers coming from e.g. C#, that virtual function calls in the constructor wouldn't call overrides (that's called dynamic binding, C++ doesn't have it), but it is almost as unintuitive that your destructor which tries to delete both objects would not be called at all, if the constructor throws an exception.