#include <iostream>
#include <string>
using namespace std;
class Horse
{
public:
void viewInfo()
{
cerr << "Name: " << name << "\n";
cerr << "Color: " << color << "\n";
cerr << "Birth Year: " << birthYear << "\n";
}
Horse(string n, string c, double y)
: name (n),
color (c),
birthYear(y)
{
}
Horse() {};
string name;
string color;
double birthYear{ 0 };
private:
};
class RaceHorse :public Horse
{
public:
void viewInfo()
{
Horse::viewInfo();
cerr << "Raced Won: " << racesWon;
}
RaceHorse(string n, string c, double y, int r)
: Horse(n,c, y),
racesWon(r)
{
}
RaceHorse() {};
int racesWon{ 0 };
};
int main()
{
Horse bucefal("Bucefal","brown",2015);
bucefal.viewInfo();
RaceHorse rossinat("Rossinat","white",2018,6);
rossinat.viewInfo();
return 0;
}
Comments
Leave a comment