当前位置: 首页>>代码示例>>C++>>正文


C++ Course::add_student方法代码示例

本文整理汇总了C++中Course::add_student方法的典型用法代码示例。如果您正苦于以下问题:C++ Course::add_student方法的具体用法?C++ Course::add_student怎么用?C++ Course::add_student使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Course的用法示例。


在下文中一共展示了Course::add_student方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1:

void 
add_course(LinkedList &sList, LinkedList &cList)
{
	int sIndex;			  // Index location of target student.
	int cIndex;			  // Index location of target course.
	Student *tempStudent; // Pointer to target student object.
	Course *tempCourse;	  // Pointer to target course object.
	bool test;			  // Bool variable, for testing whether student was 
						  // successfully added to a Course's List.

	// If the student list is empty, no point in continuing.
	if (sList.size() == 0)
	{
		cerr << "\n*** No Students in the List ***" << endl;
		return;
	}


	// First get the student selection.
	sIndex = find_student(sList);

	// If that student was not found, display error message and return.
	if (sIndex == -1)
	{
		cerr << "\n*** No Student of that Number in the List ***" << endl;
		return;
	}

	tempStudent = (Student*)sList[sIndex];
	
	// Get the course selection.
	cIndex = find_course(cList);

	// If that course was not found, return.
	if (cIndex == -1)
		return;
	
	tempCourse = (Course*)cList[cIndex];

	// Since everything is okay, add the course to the student's personal list
	tempStudent->add_course(tempCourse);

	// Now add the student to the Course's List of Students
	test = tempCourse->add_student(tempStudent);

	// Error checking.
	if (test)
		cout << "\nEnrollment for this Course updated successfully" << endl;
	else
		cerr << "\n*** Update of Enrollment for this course failed ***" << endl;
}
开发者ID:malachig,项目名称:archive,代码行数:51,代码来源:main.cpp

示例2: enrollStudentInCourse

		void Registrar::enrollStudentInCourse(std::string user_name, std::string course_name){
			int user_index = find_user_index_by_name(user_name);
			int course_index = find_course_index_by_name(course_name);

			
			if (user_index > -1 && course_index > -1){
				User* user = students[user_index];
				Course* course = courses[course_index];

				course->add_student(user);
				user->add_course(course);
			}
			else{
				std::cout << "could not find user or course: " + user_name + ", " + course_name << std::endl;
			}

		}
开发者ID:adroitcode,项目名称:VisualStudioProjects,代码行数:17,代码来源:Registrar.cpp


注:本文中的Course::add_student方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。