below is my code. So basically, i am not sure if i am overriding a base class' function. for example. In my 'famillyTruck' class i have the same name for a function named 'truckPrint'... from my experience i understand you name it the same function and have a different output and it should be fine.
But when i go to type in the code it has two functions called 'truckPrint'. Both do the same thing for the wanted output for each class. I am just trucking to eliminate any 'extra' confusion.
I also kind of noticed this for some other child class functions. Thank you for taking the time to read my post.
class truck {
public:
//default constructor
Truck();
//truck constructor with only name of truck known
Truck(string name);
//Truck constructor with only year of truck built known
Truck(int year);
//construtor with both variables known.
Truck(string name, int year);
//accessors
string getName();
void truckPrint();
protected:
string truckname;
int yearbuilt;
};
class familyTruck: public Ship
{
private:
int maxpassengers;
public:
//default constructor
familyTruck();
//only ship name known
familyTruck(string name);
//familyTruck(int year);
//only max passengers known
familyTruck(int maxOccupany);
//only ship name and year known
familyTruck(string name, int year);
// ship name, year, and max passengers known
familyTruck(string name, int year, int maxOccupancy);
//accessors
int getMaxOccupancy();
void truckPrint();
//mutators
void setMaxOccupancy();
};
int main()
{
Truck enterprise("Chevy, 1934);
enterprise.truckPrint();
familyTruck f150("Ford F150", 1990, 6);
marylee.shipPrint(); // why do i have multiple truck prints? both do what i want for family truck class
return 0;
}
void Truck::truckPrint()
{
cout << "Truck Name : " << truckname <<endl;
cout << "Year Built : " << yearbuilt <<endl;
}
{
cout << "Truck Name : " << truckname <<endl;
cout << "Year Built : " << yearbuilt <<endl;
}
void familyTruck::truckPrint()
{
cout << "Ship Name : " << shipname << endl;
cout << "Passenger Limit : " << maxpassengers <<endl;
}