我的任务是使用std set,map或multimap的某种组合来实现具有prereqs的课程集合。这项任务有点开放,我很难开始。在courseCollections.h我有以下地图和设置插入功能不会解决
//A collection of courses with no duplicates.
typedef std::set<Course, less<Course> > CourseSet;
//A map from a course to zero or more other courses.
typedef std::multimap<Course, Course, less<Course>> CourseMap;
在为CourseCatalog构造我声明如下
CourseSet coursesOffered;
CourseMap enables;
我想实现一个功能,课程添加到该集合和地图,但我得到当我尝试使用enable.insert时出现编译错误。为什么这不像我所期望的那样工作?
void addCourses (
const Course& course1,
const Course& prereqOfCourse1)
{
enables.insert(course1, prereqOfCourse1); //error Method 'insert' could not be resolved
}
谢谢。似乎有一个更深的问题,因为编译器根本无法解析启用。我正在对教练期望的内容进行非常模糊的指导,所以我直接与他联系,但是感谢您确认我期望的内容不会失误。 – Addy