use parent constructor in child class
#include <iostream>
//using parent constructor in child class
class A
{
protected:
int amount;
private:
long fuel;
char g;
public:
A(long f, char g): fuel(f), g(g), amount(0)
{
}
long getFuel()
{
return fuel;
}
};
class B: public A
{
public:
B(long f, char g): A(f, g)
{
}
int getAmount()
{
return amount;
}
};
int main() {
B test(500, 'j');
std::cout << "The fuel is: " << test.getFuel() << "\n";
}