에 " '.'전에 수업 시간에 나는 성적표 프로그램을 만들기 위해 노력하고있어. 저는 structs의 벡터 인 gradebook 클래스를 정의하는 초기 단계에 있으며 각 struct에는 학생의 이름과 그 학생의 성적에 대한 문자열이 있습니다."예상 식별자"및 "누락 된 ';' 구조체
// Creates a gradebook database that can be accessed and modified
#ifndef GRADEBOOK_H
#define GRADEBOOK_H
#include <string>
#include <vector>
#include <iostream>
#include <fstream>
using std::string;
using std::vector;
using std::cout;
using std::cin;
using std::endl;
class gradebook {
public:
//--constructors
gradebook();
// post: An empty database is constructed
//--modifiers
void add_student(string name);
// post: A new student is added who has the given name
bool remove_student(string name);
// post: If the name matches an existing student, that student is removed.
// Otherwise, return false.
void add_grades();
// post: Adds grades input from the keyboard
//--accessors
void show_total_grade(string name);
// post: Displays the cumulative grade for the student. If no student by
// that name, display a message conveying such.
void show_class_average();
// post: Displays the average grade for the class.
void show_student_grade(string name);
// post: Displays grades for all assignemnts for the given student.
void show_assignment_grade(int assignment);
// post: Displays all the grades for the given assignment number.
//--iterator functions
struct book_entry
{
string my_name;
vector<double> grades;
book_entry(string name)
{
my_name = name;
vector<double> grades;
}
void get_student(string name) {
cout << my_name << ": ";
for (auto &i : grades)
cout << i << " ";
cout << endl;
}
};
private:
string my_student_name;
string my_assignment;
vector<book_entry> my_book;
double my_grade;
};
#endif
및 구현 :
#include "gradebook.h"
#include <vector>
#include <string>
#include <iostream>
using std::string;
using std::cout;
using std::cin;
using std::vector;
//--constructors
gradebook::gradebook() {
vector<book_entry> my_book;
}
//--modifiers
void gradebook::add_student(string name) {
//my_book.next() =
}
//--accessors
void gradebook::show_student_grade(string name) {
book_entry.get_student(string name);
}
void gradebook::show_assignment_grade(int assignment) {
}
//--iterator functions
내가 MSVS 2013 사용하고 있는데, 나는이 프로젝트를 빌드 할 때, 내가 구현의 라인 (23)에 오류가 여기에 gradebook.h 헤더입니다 (book_entry.get_student(string name);
). 오류는 "누락되었습니다"; 전에 '.' ". 그 줄의 기간은 구불 구불 한 빨간 밑줄을 긋고, 내가 그 위에 마우스를 올리면 나는 "식별자를 기대했다"라는 다른 오류를 얻습니다. 그것은 내가 설정 한 구조체를 사용하는 방법을 오해하고있는 것 같습니다. 이 문제를 어떻게 해결할 수 있습니까?
내가 어떻게 수정합니까? 마지막 중괄호 뒤에 세미콜론이 있습니다. – spartanhooah
나는 두 개를 가지고있다. 하나는 구조체의 끝에, 개인 데이터 섹션 바로 앞에, 그리고 다른 하나는'#endif '앞에 위치한다. – spartanhooah