本文整理汇总了C++中Students::size方法的典型用法代码示例。如果您正苦于以下问题:C++ Students::size方法的具体用法?C++ Students::size怎么用?C++ Students::size使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Students
的用法示例。
在下文中一共展示了Students::size方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main(int argc, char* argv[]) {
ifstream file;
string data;
vector<string> tokens;
Courses courses;
Students students;
file.open("courses.conf");
if (!file.is_open()) {
cout << "Failed opening courses.conf." << endl;
return 0;
}
while (getline(file, data)) {
tokens = str_split(data, ',');
// data: WEEKDAY,COURSE-ID,SPACE
Course* course = new Course(*(tokens[0].c_str()) - '0',
tokens[1],
atoi(tokens[2].c_str()));
courses.push_back(course);
}
file.close();
file.open("students.conf");
if (!file.is_open()) {
cout << "Failed opening students.conf." << endl;
return 0;
}
while (getline(file, data)) {
tokens = str_split(data, ',');
// data: STUD-ID,COURSE-ID1,COURSE-ID2,...,COURSE-IDN
Student* student = new Student(tokens[0]);
if (tokens.size() > 1) {
for (size_t i = 1; i < tokens.size(); ++i) {
for (size_t j = 0; j < courses.size(); ++j) {
if (courses[j]->getCourseId() == tokens[i]) {
if (courses[j]->addStudent(student)) {
// we have found a room for this student
// in the course he requested, so we are breaking
// the search for room.
// NOTE: we are not break;'ing when we find
// a matching course because there might be
// room in another day for this course.
break;
}
}
}
}
}
students.push_back(student);
}
file.close();
// clean output files
ofstream output;
output.open("courses.out");
output.close();
output.open("students.out");
output.close();
for (size_t i = 0; i < courses.size(); ++i) {
courses[i]->print("courses.out");
}
for (size_t i = 0; i < students.size(); ++i) {
students[i]->print("students.out");
}
for (size_t i = 0; i < courses.size(); ++i) {
delete courses[i];
courses[i] = 0;
}
for (size_t i = 0; i < students.size(); ++i) {
delete students[i];
students[i] = 0;
}
return 0;
}