so I'm working through a project and I'm stuck on a certain error that is being thrown. error: no match for 'operator=' in 'someCourses = cCourse::getCourseWithIdentifier(std::basic_string<char>(((const char*)"CS 2800"), (*(const std::allocator<char>*)(& std::allocator<char>()))))'|
Here is the code I'm using that generates the error.
std::cout << std::endl << "Courses titled Computer Science I:" << std::endl;
auto someCourses = cCourse::getCoursesWithTitle("Computer Science I");
std::for_each(
someCourses.begin(),
someCourses.end(),
OutputPrinter());
std::cout << std::endl << "Courses with identifier CS 2800:" << std::endl;
someCourses = cCourse::getCourseWithIdentifier("CS 2800"); //Error thrown here
std::for_each(
aCourse.begin(),
aCourse.end(),
OutputPrinter());
And here is the code from the class that it's calling.
std::set<cCourse *>
cCourse::getCoursesWithTitle(std::string title)
{
std::set<cCourse *> resultSet;
for(auto it = s_allCourses.begin();
it != s_allCourses.end();
++it)
{
if((*it)->getTitle() == title)
{
resultSet.insert(*it);
}
}
return resultSet;
}
//////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////
cCourse *cCourse::getCourseWithIdentifier(std::string identifier)
{
cCourse *result = nullptr;
for(auto it = s_allCourses.begin();
it != s_allCourses.end() && result == nullptr;
++it)
{
if((*it)->getIdentifier() == identifier)
{
result = *it;
}
}
return result;
}
And here is the part of the header file it's using.
/// This function creates a new Student instance with the
/// specified name and returns a pointer to the new student.
static cCourse *createCourse(
std::string identifier,
std::string title
);
/// This function returns a set of pointers to existing
/// Student instances that have the specified name. If no
/// student has the name, an empty set is returned.
static std::set<cCourse *>getCoursesWithTitle(
std::string title
);
I haven't coded in C++ in a while I'm mostly used to C# but from what I can remember I think I'm missing an operator overload but I'm not 100% sure. Any help would be greatly appreciated.
Aucun commentaire:
Enregistrer un commentaire