In this underlying code I have used parameterized constructor both in base class and in derived class but this is not working, I understand that I haven't passed any argument to the the constructor which has been inherited from A by B. How to get out of this mess?
Code:#include<iostream> using namespace std; class A { int x; public: A(int x) { this->x=x; cout<<"I am in BASE CONSTRUCTOR "<<x<<endl; } }; class B:public A { int y; public: B(int y) { this->y=y; cout<<"I am in BASE CONSTRUCTOR "<<y<<endl; } }; int main() { A obj(123); B ob(345); return 0; }