У меня есть класс ToDo, у которого есть описание, дата и приоритет в качестве закрытых переменных-членов.
Я пытаюсь взять заполненную задачу и добавить ее в глобальный массив задач.
Я установил все переменные-члены объекта, используя this-> description, this-> date и this-> priority, но когда я пытаюсь добавить объект с помощью следующего - TODO_GLOBAL_ARRAY [CURRENT_LOC_OF_ARRAY] = this; - Я получаю сообщение об ошибке "нет жизнеспособных перегруженных" = ".
Я также пытался создать экземпляр объекта ToDo и передать его в массив, но он по-прежнему оставляет исходный объект без данных и не распечатывает правильно.
//ToDo Header
#include <string>
using std::string;
#ifndef TODOLIST
#define TODOLIST
class ToDoList{
private:
string description;
string date;
int priority;
public:
bool addToList(ToDoList todoItem);
bool addToList(string desc, string date, int priority);
bool getNextItem(ToDoList &toDoItem);
bool getNextItem(string &desc, string &date, int &priority);
bool getByPriority(ToDoList *results, int priority);
bool getByPriority(ToDoList *results, int priority, int &resultSize);
void printToDo();
void printToDo(ToDoList aToDo);
void printToDoList(ToDoList *aToDoList);
void printToDoList(ToDoList *aToDoList, int size);
ToDoList();
ToDoList(string desc, string date, int priority);
// TODO: implement method to get ToDo from usr input
};
#endif
extern ToDoList usr_TODO_list[];
extern const int MAX_ITEMS_TODO;
extern int SIZE_OF_USR_LIST;
extern int NEXT_INDEX;
// From ToDo.cpp
bool ToDoList::addToList(string desc, string date, int priority){
if (SIZE_OF_USR_LIST == MAX_ITEMS_TODO) {
return false;
}
else{
ToDoList aToDo;
this->description = desc;
this->date = date;
this->priority = priority;
usr_TODO_list[SIZE_OF_USR_LIST] = this;
SIZE_OF_USR_LIST++;
return true;
}
}
// From main.cpp
using namespace std;
ToDoList usr_TODO_list[100];
int const MAX_ITEMS_TODO (100);
int SIZE_OF_USR_LIST = 0;
int NEXT_INDEX = 0;
int main()
{ // etc...
Ожидается: для передачи объекта в массив с помощью 'this'
Факт: ошибка не перегружена '=' ошибка