0

I have a code like this

class Base {
public:
    Base() {};
};

class Derived : public Base {
public:
    Derived() {cout << "Derived" << endl;}
};

int main() {
    Derived a(); // Only called base constructor
    Derived b;   // called derived constructor
}

What is the difference between these two calls? My understanding is that base constructor is always called before derived constructor? Why is the derived constructor skipped?

Thanks,

Mira
  • 3
  • 2

0 Answers0