c++ - Do default constructors need to call base class default constructors? -


was reading this answer , surprised me, suggestion must always call base class constructor in derived class constructor. if working default constructors, consider:

class bar : public foo { private: int y;  public: bar() : foo(), y(0) { }  ... 

is call foo() necessary here?

you not need explicitly call base class constructor in constructor, in case compiler implicitly calls default constructor, or compile-time error, if none callable.
same applies members non-pod.

an alternative member initialiser list only consisting of delegation constructor of class, creating delegating constructor.


Comments

Popular posts from this blog

apache - Remove .php and add trailing slash in url using htaccess not loading css -

javascript - jQuery show full size image on click -