I have this as a member of the class TASK.
list<Stimulation*> listOfStimulations;
And the rest of my class definition;
class Task
{
public:
Task();
Task(const Task& obj);
Task(const Task&& obj);
Task(string, list<Stimulation*>);
Task& operator+=( Stimulation* obj);
Stimulation* Task::operator[](int i) const;
};
#endif
And I want to be ale to access each Stimulation in the list.
I know I should be using vector, but using list is a requirement.
How would I overload []?
I've tried
Stimulation* Task::operator[](int i) const
{
list<Stimulation*>::const_iterator iter;
iter = listOfStimulations.begin();
advance(iter, i);
return *iter;
}
My main issue is that this code isn't letting me access the elements of my list.
For example, listOfStimulations[i] does not work, and won't let me access the function display within the Stimulations class.