I inherited the constructor from class Cars
to add a seats
parameter. Is there any way to simply add the one parameter I want without copying the inherited constructor's whole parameter list?
#include <iostream>
using namespace std;
class Cars {
public:
string brand;
string type;
string category;
string origin;
Cars (string abrand, string atype, string acategory, string aorigin) {
brand = abrand;
type = atype;
category = acategory;
origin = aorigin;
}
void statement() {
cout << brand << " " << type << " is a "<< category << " from " << origin;
}
};
class Seats : public Cars{
public:
int seat;
Seats (int aseat) {
seat = aseat;
}
void statement2() {
cout << brand << " " << type << " has " << seat << " seats.";
}
};
int main() {
Cars car1 ("BMW", "320i", "Sedan", "Germany");
Cars car2 ("Ford", "Mustang", "Sports", "USA");
Cars car3 ("Chevrolet", "Suburban", "SUV", "USA");
Cars car4 ("Toyota", "Land Cruiser", "SUV", "Japan");
Seats car6 ("Ford", "Mustang", "Sports", "USA", 2);
Cars car5 ("Rolls Royce", "Phantom", "Luxury", "Great Britain");
car4.statement();
car6.statement2();
return 0;
}