#include<bits/stdc++.h>
using namespace std;
class Vehicle
{
private:
int speed;
public:
Vehicle(int x)
{
speed=x;
cout << "Vehicle's parametrized constructor called" << endl;
}
};
class Car : public Vehicle
{
public:
Car() : Vehicle(5)
{
cout << "Car's constructor called" << endl;
}
};
int main()
{
Car a;
}
Output-
Vehicle's parametrized constructor called
Car's constructor called
Since the access specifier is public, speed is not inherited. What does 5 get assigned to as there is no speed member in Car?