Does a subclass need a default constructor?

I am learning about inheritance right now, and there is one thing I haven't found a solid answer on. If I have three classes one being a super and two subclass, would my subclasses need a default constructor if they inherit the same fields? Class b doesn't have a default constructor because it inherits its fields from A, where as class c has different fields, therefore it would need its own default constructor.

class A {
  
    private:
        int a;
        int b;
    
    public:
        A();
        A(int, int);
    
};

class B: public A {
  
    public:
        B(int, int);
    
};

class C : public A {
  
    private:
        int c;
    
    public:
        C();
        C(int, int);
    
};

anything is greatly appreciated.



Read more here: https://stackoverflow.com/questions/66326861/does-a-subclass-need-a-default-constructor

Content Attribution

This content was originally published by Lucas Dahl at Recent Questions - Stack Overflow, and is syndicated here via their RSS feed. You can read the original post over there.

%d bloggers like this: