My question would be the output statements for my TaskList.cpp. For outputFromList() I want to output the Task(s) the user has input into the vector and for getTask(int num) I want to get the specific task at the index of the vector. I'm not sure if my implementation is correct, because I'm still a bit hazy on objects.
Some comments on your code:
1. there is no need for the using directive in the header files, for any string data type in the headers just use std::string though you might have to #include<vector>
2. the two header files should be combined; TaskList has a vector<Task> data member, taskList (which is itself a bad idea to name a data member so similar to the Class name) and keeping the two classes in the same header and their implementations in the same source file avoids the danger of splitting them up in case you're shipping your program
3. addToList() argument should be const Task& t, removeFromList() argument const int&
4. outputFromList(), getTask() should both be const
5. taskList is vector<Task>, so before you can do cout<<taskList.at(index).aTask you need to overload the << operator for class Task, also you don't need the .at(index) but it can be written as taskList[index].aTask since [] is overloaded for vectors
6. index needs to be unsigned int and not just int since it is used in conjunction with taskList.size() that returns size_t which is an unsigned int
7. in class Task, getType(), getDeadline(), getDescription() should all be const
8. in setType() and setDescription() the arguments could be const string& and for setDeadline() const int&
@gunnerfunner thanks for the comments. There are some things that I'm confused about.
1. Why would I need to pass-by-reference and not just by value. Since I am just storing the each task into an element of the vector wouldn't pass-by-value suffice?
2. I'm not sure if creating Task object aTask makes sense in my program. What I had in mind was create a Task object that has the member variables. Then at the specific index of the vector, I can manipulate that Task by either printing it out, removing the whole task, etc. Maybe I could create it was a member variable in my class, since I'm getting compilation errors stating that there's no member aTask in Task
Side note: As per the specs of my assignment, Task is a base class with 3 different derived classes, therefore I don't think I should include it into my TaskList.
Why would I need to pass-by-reference and not just by value. Since I am just storing the each task into an element of the vector wouldn't pass-by-value suffice?
When you pass by value you're actually passing copies of the Task objects to the function and these draws resources (to make the copies) and consequently slows down your program depending on how many objects there are and the size of each object. When you pass by reference you're passing the object itself to the function but note that we have a safeguard - const - that means that the function can't make any changes to the object we pass to it unless, of course, we need it to in which case the const qualifier is dropped
I'm not sure if creating Task object aTask makes sense in my program
Probably not because someTask has already been declared as vector<Task>. So as long as you overload the insertion operator << you should be able to print out the vector elements (i.e. the Task objects) directly without having an additional Task object in between
Maybe I could create it was a member variable in my class
You can't have a class object as a non-static member of the class itself, you could have a reference or pointer to a class object as a data member though. However in your case I don't really see the need for any of these
It seems you're making some honest efforts with your assignment yourself in contrast to some who outright copy/paste their assignment and request 'help' (i.e for someone to do their assignment for them). So as you progress further with it you're welcome to circle back with any additional queries you might have.