Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

IN C++ WITH HEADER FILES, IMPLEMENTATION FILES AND ONE MAIN FILE Polymorphism, Pointers, and Virtual Functions Construct a base class called athlete. This class should

IN C++ WITH HEADER FILES, IMPLEMENTATION FILES AND ONE MAIN FILE

Polymorphism, Pointers, and Virtual Functions

Construct a base class called athlete. This class should have a member attribute called sport which contains the name of the sport the athlete plays. This class should have two virtual functions called scorePoints() and move().

Write two derived classes from the base athlete class. These classes should pertain to a particular sport. For example, basketballPlayer or baseballPlayer would be subclasses of the athlete class. The derived classes should put the name of the sport by default into the sport member attribute. Additionally, they should redefine the scorePoints() and move() functions with information related that particular sport. For example, a hockeyPlayer class could have I score points by shooting the puck in the net for its scorePoints() function and I move by skating on ice skates for its move() function.

Your driver file should include a processAthlete() function which accepts as a parameter an object of the base athlete class. In the function, you should call the accessor for the sport attribute, as well as the two virtual functions. The proper information related to the class should be displayed (the name of the sport, how points are scored, and how the athlete moves). This function should be called twice, once for each object of the two different derived classes.

You are required to write header files for the base athlete class as well as the derived athlete classes. Function bodies need to be defined in implementation files and the main function will be in main.cpp. Make sure your program is properly documented.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Intelligent Databases Technologies And Applications

Authors: Zongmin Ma

1st Edition

1599041219, 978-1599041216

More Books

Students also viewed these Databases questions

Question

How do Excel Pivot Tables handle data from non OLAP databases?

Answered: 1 week ago