how to make sure the correct type is returned when call with overriden
- User
how to make sure the correct type is returned when call with overriden
- Assistant
- User
below are headers and cpp file, modify it so when gettype is called the correct type override #include "Assignment.h" #include
using namespace std;
Assignment::Assignment() { mName = ""; mPoints = 0; mTotalPoints = 1; mComplete = false; mPriority = 0; }
Assignment::~Assignment() {
}
void Assignment::setName(std::string name) { mName = name; }
std::string Assignment::getName() { return mName; }
std::string Assignment::getType() { return "Assignment"; }
bool Assignment::isComplete() { return mComplete; }
void Assignment::complete() { mComplete = true; }
std::string Essay::getType() { return "Essay"; }
std::string Essay::getPrompt() { return mPrompt; }
std::string Exam::getType() { return "Exam"; }
std::string Homework::getType() { return "Homework"; } #include
class Assignment {
public: Assignment(); virtual ~Assignment(); void setName(std::string name); std::string getName(); double getPoints(); int getTotalPoints(); void setPoints(double points); void setTotalPoints(int totalPoints); bool isComplete(); void complete(); std::string getType();
- Assistant