Hi,
A few things:
I don't think you should have a generic class as one of your task types. Generic was meant to be for the base class. I woud have called the base class Task.
With your file names, name them the same as the classes - try to avoid putting more than one class declaration is a file. So have 1 cpp file and 1 header file for each class.
Avoid using
NULL
,
nullptr
was invented to fix the problems that
NULL
causes.
I would have virtual for the derived functions in the class declaration. Also the
override
keyword.
One should also have a virtual destructor.
Avoid having protected data, it's just as bad as having public data.
Pas std::string by const reference:
1 2 3 4
|
void GenericTask::set_date(const std::string& date_input) {
due_date.set_date(date_input);
}
| |
Even better: use a member initialization list.
What is the point of the get and set type - you shouldn't need it for polymorphism.
For polymorphism to work a function needs to declared to receive a pointer to base class, but is sent a pointer to derived class. That way it will call the derived class function - which is usually what you want.
Your print function is deleting a node - is that what you want? Why does it create a new node?