• Source
    1. #include <iostream>
    2. using namespace std;
    3.  
    4. class A {
    5. private :
    6. int x;
    7. public :
    8. A () {
    9. cout << "I anyway use parameter-less constructors, they are called always" << endl;
    10. }
    11. A (const int& x) {
    12. this->x = x;
    13. cout << "I can use the parent constructor" << endl;
    14. }
    15. };
    16.  
    17. class B : public A {
    18. private :
    19. int y;
    20. public :
    21. B() {
    22.  
    23. }
    24. B (const int& x, const int& y) : A (x) {
    25. this->y = y;
    26. }
    27. };
    28.  
    29. int main() {
    30.  
    31. B* b = new B(1,2);
    32. B* b1 = new B();
    33. return 0;
    34. }