2016-12-08 24 views
0

私はC++の初心者で、C++に関する知識はありません。私は学生とモジュールのためのコードを書いています。要件はモジュールと学生に最終スコア、重複を表示する必要があります。私がケース5とケース6を書くとき、コンパイルした後、それは以下のエラーを示します。エラーC2360:エラーC2361:エラーC2039:

エラーC2360:「コード」の初期設定は「ケース」ラベル によってスキップされ「コード」 エラーC2361の宣言を参照してください。「コード」の初期設定は「デフォルト」のラベルによってスキップされ は、「コード」の宣言を参照してください

エラーC2039: 'のgetIdは': 'getModule': 'のstd ::ベクトル< _Ty>'

[_Ty =学生]とエラーC2039のメンバーではないSTD」のメンバーではありません。 :ベクトル< _Ty> ' with [_Ty = Student]

MAIN.CPP

#include <iostream> 
#include <fstream> 
#include <string> 
#include <vector> 
#include <sstream> 
#include <algorithm> 
#include <cmath> 
#include <vector> 
#include "Student.h" 
#include "Module.h" 
using namespace std; 

void printMenu(); 
vector<Student> readFile(); 
void liststudentRecord(vector<Student>); 
string trim(string); 
bool isValidClasscode(string s); 
bool isvalidStudentid(string s); 
bool test1Ascending(Student s1, Student s2); 
bool test1Desscending(Student s1, Student s2); 
bool test1finalScoreAscending(Student s1, Student s2); 
vector<Module> readFile2(); 
void listmoduleRecord(vector<Module>); 
bool moduleName (Module m1, Module m2); 
vector<Student> getStudentByModule(vector<Student>,string); 
bool isDuplicateStudentRecord(vector<Student>, Student); 


//gloval variable 
vector<Student> duplicates; 

int main() { 

    int choice; 
    vector<Student> students;//list of student 
    vector<Module> modules; 
    vector<Student> list; 


    do { 
     printMenu(); 
     cin >> choice; 

     switch(choice) { 
     case 1: 
      cout << "Read Student file ... " << endl; 
      students =readFile(); 
      cout<<"Number of records read: " <<students.size() <<endl; 
      break; 
     case 2: 
      liststudentRecord(students); 
      break; 
     case 3: 
      cout << "Read Module file ... " << endl; 
      modules =readFile2(); 
      cout<<"Number of records read: " <<modules.size() <<endl; 
      break; 
     case 4: 
      listmoduleRecord(modules); 
      break; 

     case 5: 
      liststudentRecord(duplicates); 
      break; 
     case 6: 
      cout << "Enter Module Code: "; 
      string code; 
      cin >> code; 
      list = getStudentByModule(students, code); 
      for (int i=0; i < list.size(); i++){ 
       Student s = list.at(i); 
       cout << s.toString() << endl; 
      } 
      cout<<"List Student by Module Code"<<endl; 
      break; 
     case 7: 
      //http://www.cplusplus.com/reference/algorithm/sort/ 
      //sort(students.begin(), students.end(), test1finalScoreAscending); 
      sort(students.begin(), students.end(),test1finalScoreAscending); //finalScoreAcending 
      break; 
     case 8: 
      break; 
     case 9: cout << "Exiting program... " << endl; break; 
     default: 
      cout << "Invalid option specified. Please try again" << endl; 
     } 
    } while(choice != 9); 

    return 0; 
} 

void printMenu() { 
    cout << "Menu" << endl; 
    cout << "----" << endl; 
    cout << "[1] Read student file" << endl; 
    cout << "[2] List student records" << endl; 
    cout << "[3] Read module file" << endl; 
    cout << "[4] List module records" << endl; 
    cout << "[5] List Duplicate Record" << endl; 
    cout << "[6] Display Student by Module" << endl; 
    cout << "[7] Sort by Final Score" <<endl; 
    cout << "[8] Write to file" << endl; 
    cout << "[9] Exit" << endl; 
    cout << "Choice: "; 
} 

vector<Student>readFile(){ 
    vector<Student>students; 
    string filename; 
    ifstream inputFile; 

    cout << "Enter filename: "; 
    cin >> filename; 

    inputFile.open(filename, ios::in);//open file, read only 
    if(inputFile.is_open()){ 
     while (inputFile.good()){ 
      string line; 
      getline(inputFile, line); 

      Student s; //create a new student 

      //extract id 
      int i = line.find(","); 
      string id = trim(line.substr(0, i));// extract id 
      s.setId(id); // set student id 
      line = line.substr(i+1);// remove id form line 
      /*if(isvalidStudentid(id)){ 
       string s = id.substr(0,1); 
       const char* s = id.substr(1,7); 
      }*/ 

      //extract name 
      i = line.find(","); 
      string name = trim(line.substr(0, i)); // extract name 
      s.setName(name); //set student name 
      line = line.substr(i+1); //remove name from line 

      //extract classcode 
      i = line.find(","); 
      string classcode = trim(line.substr(0, i)); 
      s.setClasscode(classcode); 
      line = line.substr(i+1); 
      if(isValidClasscode(classcode)){ 
       string module = classcode.substr(0,6); 
       s.setModule(module); 
       string status = classcode.substr(7,9); 
       char *ft ="FT"; 
       if(status.compare(ft)==0){ 
        s.setFulltime(true); 
       }else{ 
        s.setFulltime(false); 
       } 
       string classnumber = classcode.substr(9,11); 
       s.setClassnumber(classnumber); 
      } 


      //to use a for-loop for attendance 
      for (int j =0; j < 10 ; j++){ 
       i = line.find(","); 
       string attendance = trim(line.substr(0, i)); 
       s.setAttendance(j, attendance); 
       line = line.substr(i+1); 
      } 

      //to extreact test1 
      i = line.find(","); 
      int test1 = stoi(line.substr(0, i)); 
      s.setTest1(test1); 
      line = line.substr(i+1); 

      //to extreact test2 
      i = line.find(","); 
      int test2 = stoi(line.substr(0, i)); 
      s.setTest2(test2); 
      line = line.substr(i+1); 


      //to extreact tutorial 
      i = line.find(","); 
      int tutorial = stoi(line.substr(0, i)); 
      s.setTutorial(tutorial); 
      line = line.substr(i+1); 

      //to extreact exam 
      i = line.find(","); 
      int exam = stoi(line.substr(0, i)); 
      s.setExam(exam); 
      line = line.substr(i+1); 


      //need to do validationfirst 
      //to only add the valid student 

      if(isDuplicateStudentRecord(students, s) == false){ 
      students.push_back(s); //add student to list 
      } else { 
       duplicates.push_back(s); 
      } 
      //cout<< line << endl; 
     } 
     inputFile.close(); 
    }else{ 
     cout << "Invalid file" << endl; 
    } 

    return students; 
} 

void liststudentRecord(vector<Student> list){ 
    int numberStudents = list.size(); 

    if (numberStudents > 0){ 
     for (int i = 0; i < numberStudents; i++){ 
      Student s = list.at(i); 
      cout << s.toString() << endl; 
     } 
    }else{ 
      cout << "Empty list" <<endl; 

     } 
} 

bool test1Ascending(Student s1, Student s2){ 
    return s1.getTest1() < s2.getTest1(); 
} 

bool test1Descending(Student s1, Student s2){ 
    return s1.getTest1() < s2.getTest1(); 
} 

bool finalScoreAscending(Student s1, Student s2){ 
    return s1.getFinalScore() < s2.getFinalScore(); 
} 

bool isvalidStudentid(string s){ 
    int i; 

    if(s.length() !=8){ 
     return false;} //first check th length is 8 

    if (s.at(i) != 'S') { 
     return false;} //start with s 

    for (i =1 ; i<8; i++){ //7 digit 
     if(isdigit(s.at(i))==0){ 

      return false; 
     } 
    } 

    return false; 
} 

bool isValidClasscode(string s){ 
    int i; 

    if(s.length() !=11){ 
    return false;} //first check th length is 8 


    for (i =0 ; i<3; i++){ // first 3 char are letters 
     if(isalpha(s.at(i))==0){ 
     return false;} 
    } 

    for (i =3 ; i<6; i++){ //next 3 char are number 
     if(isdigit(s.at(i)) == 0){ 
     return false;} 

    } 
     if (s.at(6) != '-') { 
     return false;} //has a hyphen 

     if (s.at(7) != 'F' && s.at(7) != 'P') { 
     return false;} 

     if (s.at(8) != 'T') { 
     return false;} // T 

     if (isdigit(s.at(9)) == 0 || isdigit(s.at(10)) == 0){ 
     return false;} 


    return false; 
} 

vector<Module> readFile2(){ 
    vector<Module>modules; 
    string filename; 
    ifstream inputFile; 

    cout << "Enter filename: "; 
    cin >> filename; 

    inputFile.open(filename, ios::in);//open file, read only 
    if(inputFile.is_open()){ 
     while (inputFile.good()){ 
      string line; 
      getline(inputFile, line); 

      Module m; //create a new student 

      //extract name 
      int i = line.find(","); 
      string modulecode = trim(line.substr(0, i));// extract id 
      m.setModulecode(modulecode); // set student id 
      //cout << id<< endl; 
      line = line.substr(i+1);// remove id form line 
      //cout << line << endl; 

      //extract id 
      i = line.find(","); 
      string modulename = trim(line.substr(0, i)); // extract name 
      m.setModulename(modulename); //set student name 
      line = line.substr(i+1); //remove name from line 



      //to extreact test1 
      i = line.find(","); 
      int test1 = stoi(line.substr(0, i)); 
      m.setTest1(test1); 
      line = line.substr(i+1); 

      //to extreact test2 
      i = line.find(","); 
      int test2 = stoi(line.substr(0, i)); 
      m.setTest2(test2); 
      line = line.substr(i+1); 


      //to extreact tutorial 
      i = line.find(","); 
      int tutorial = stoi(line.substr(0, i)); 
      m.setTutorial(tutorial); 
      line = line.substr(i+1); 

      //to extreact exam 
      i = line.find(","); 
      int exam = stoi(line.substr(0, i)); 
      m.setExam(exam); 
      line = line.substr(i+1); 

      modules.push_back(m); //add student to list 

      //cout<< line << endl; 
     } 
     inputFile.close(); 
    }else{ 
     cout << "Invalid file" << endl; 
    } 

    return modules; 

} 

void listmoduleRecord(vector<Module> list){ 
    int numberModules = list.size(); 

    if (numberModules > 0){ 
     for (int i = 0; i < list.size(); i++){ 
      Module m = list.at(i); 
      cout << m.toString() << endl; 
     } 
    }else{ 
      cout << "Empty list" <<endl; 

     } 
} 

vector<Student> getStudentByModule(vector<Student> students,string code){ 
    vector<Student> list; 
    for (int i=0; i< students.size(); i++){ 
     Student s = students.at(i); 
     if (code.compare(current_module) == 0){ 
      list.push_back(s); 
     } 
    } 
    return list; 
} 



bool isDuplicateStudentRecord(vector<Student> student, Student s){ 
    string id = student.getId(); 
    string name = student.getName(); 
    string module = student.getModule(); 
    for(int i=0; i< student.size(); i++){ 
     Student s = student.at(i); 
     string current_id = s.getId(); 
     string current_name = s.getName(); 
     string current_module = s.getModule(); 
     if(id.compare)(current_id) == 0 && 
      name.compare(current_name) == 0 && 
      (module.compare(current_module) == 0);{ 
      return true; 
     } 
    } 
    return false; 
} 


//http://stackoverflow.com/a/6500499/3839235 
string trim(string s){ 
    s.erase(0, s.find_first_not_of(' ')); //prefixing spaces 
    s.erase(s.find_last_not_of(' ')+1); //surfixing spaces 
    return s; 
} 

Module.cpp

#include "Module.h" 
#include <sstream> 
using namespace std; 

Module::Module(void){ 
} 


    string Module:: getModulecode(){ 
     return modulecode; 
    } 

    void Module::setModulecode(string modulecode){ 
     this->modulecode = modulecode; 
    } 

    string Module:: getModulename(){ 
     return modulename; 
    } 

    void Module:: setModulename(string modulename){ 
     this->modulename = modulename; 
    } 

    int Module:: getTest1(){ 
     return test1; 
    } 
    void Module:: setTest1(int value1){ 
     test1 = value1; 
    } 

    int Module:: getTest2(){ 
     return test2; 
    } 
    void Module:: setTest2(int value2){ 
     test2 = value2; 
    } 

    int Module:: getTutorial(){ 
     return tutorial; 
    } 
    void Module:: setTutorial(int value3){ 
     tutorial = value3; 
    } 

    int Module:: getExam(){ 
     return exam; 
    } 
    void Module:: setExam(int value4){ 
     exam = value4; 
    } 


    string Module::toString(){ 
     stringstream ss; 

     ss<<"Module Code: " << modulecode<< "-"<< modulename <<endl; 
     ss << "Test 1: " << getTest1Percentage() << "%" << endl; 
     ss << "Test 2: " << getTest2Percentage() << "%" << endl; 
     ss << "Tutorial: " << getTutorialPercentage() << "%" << endl; 
     ss << "Exam: " << getExamPercentage() << "%" << endl; 
     //ss<< "Score percentage: " << getScorePercentage() << "%"<< endl; 
     ss<< "Final score: " << getFinalScore() << "%" <<endl; 
     return ss.str(); 
    } 

    int Module::getTest1Percentage(){ 
     int result; 
     result = (getTest1() * 100)/100; 
     return result; 
    } 

    int Module::getTest2Percentage(){ 
     int result; 
     result = (getTest2() * 100)/100; 
     return result; 
    } 

    int Module::getTutorialPercentage(){ 
     int result; 
     result = (getTutorial() * 100)/100; 
     return result; 
    } 

    int Module::getExamPercentage(){ 
     int result; 
     result = (getExam() * 100)/100; 
     return result; 
    } 

    int Module::getFinalScore(){ 
     int final = getTest1Percentage()+getTest2Percentage()+getTutorialPercentage()+getExamPercentage(); 
     return final; 
    } 


    /*int Module::getFinalScore(){ 
     int final = test1+test2+tutorial+exam; 
     return final; 
    }*/ 

Student.cpp

#include "Student.h" 
#include <sstream> 
using namespace std; 

Student::Student(void){ 
} 


    string Student:: getId(){ 
     return id; 
    } 
    void Student:: setId(string newid){ 
     id = newid; 
    } 

    string Student:: getName(){ 
     return name; 
    } 
    void Student:: setName(string name){ 
     this->name = name; 
    } 

    string Student:: getClasscode(){ 
     return classcode; 
    } 
    void Student::setClasscode(string classcode){ 
     this->classcode = classcode; 
    } 

    string Student:: getAttendance(int i){ 
     return attendance[i]; 
    } 
    void Student:: setAttendance(int i, string value){ 
     attendance[i] = value; 
    } 

    int Student:: getTest1(){ 
     return test1; 
    } 
    void Student:: setTest1(int value1){ 
     test1 = value1; 
    } 

    int Student:: getTest2(){ 
     return test2; 
    } 
    void Student:: setTest2(int value2){ 
     test2 = value2; 
    } 

    int Student:: getTutorial(){ 
     return tutorial; 
    } 
    void Student:: setTutorial(int value3){ 
     tutorial = value3; 
    } 

    int Student:: getExam(){ 
     return exam; 
    } 
    void Student:: setExam(int value4){ 
     exam = value4; 
    } 


    string Student::toString(){ 
     stringstream ss; 

     ss << name << "(" <<id << ")" << endl; 
     ss << classcode << endl; 
     for(int i=0; i<10; i++){ 
      ss << getAttendance(i) << " "; 
     } 
     ss << endl; 
     ss << "Test 1: " << test1 << endl; 
     ss << "Test 2: " << test2 << endl; 
     ss << "Tutorial: " << tutorial << endl; 
     ss << "Exam: " << exam << endl; 
     ss<< "Attendance percentage: " << getAttendancePercentage() << "%"<< endl; 
     ss<< "Final score: " << getFinalScore() <<endl; 
     return ss.str(); 
    } 


    double Student::getAttendancePercentage(){ 
     int n =0 ; // n will be the total number of "yes" 
     for (int i=1; i<10; i++){ 
      string s = getAttendance(i); 
      char*yes = "yes"; 
      if(s.compare(yes)== 0){ 
       n++; 
      } 
     } 
     double percentage = n/10.0 * 100; //avoud interger division 
     return percentage; 
    } 


    int Student::getFinalScore(){ 
     int final = test1+test2+tutorial+exam; 
     return final; 
    } 

    /*string Student::getModule() { return module; } 
    void Student::setModule(string m) { module = m;} 
    bool Student::getFulltime() { return fulltime; } 
    void Student::setFulltime(bool v) { fulltime = v;} 
    string Student::getClassnumber() { return classnumber; } 
    void Student::setClassnumber(string v) { classnumber = v;} */ 


    string Student:: getModule(){ 
     return module; 
    } 
    void Student:: setModule(string m){ 
     module =m; 
    } 

    bool Student:: getFulltime(){ 
     return fulltime; 
    } 
    void Student:: setFulltime(bool v){ 
     fulltime = v; 
    } 

    string Student:: getClassnumber(){ 
     return classnumber; 
    } 

    void Student:: setClassnumber(string c){ 
     classnumber = c; 
    } 

Module.h

#ifndef MODULE_H 
#define MODULE_H 

#include <string> 
using namespace std; 

class Module { 

public: 
    Module(); 

    string getModulecode(); 
    void setModulecode(string); 

    string getModulename(); 
    void setModulename(string); 

    int getTest1(); 
    void setTest1(int); 

    int getTest2(); 
    void setTest2(int); 

    int getTutorial(); 
    void setTutorial(int); 

    int getExam(); 
    void setExam(int); 

    string toString(); //to displayed info 
    int getTest1Percentage(); 
    int getTest2Percentage(); 
    int getTutorialPercentage(); 
    int getExamPercentage(); 

    int getFinalScore(); 

private: 
    string modulecode; 
    string modulename; 
    int test1; 
    int test2; 
    int tutorial; 
    int exam; 

}; 


#endif //MODULE_H 

Student.h

#ifndef STUDENT_H 
#define STUDENT_H 

#include <string> 
using namespace std; 

class Student { 
//methods 
public: 
    Student(); 

    string getId(); 
    string getName(); 
    string getClasscode(); 
    string getAttendance(int); 
    int getTest1(); 
    int getTest2(); 
    int getTutorial(); 
    int getExam(); 

    void setId(string); 
    void setName(string); 
    void setClasscode(string); 
    void setAttendance(int, string); 
    void setTest1(int); 
    void setTest2(int); 
    void setTutorial(int); 
    void setExam(int); 

    string toString(); //to displayed info 
    double getAttendancePercentage(); 

    int getFinalScore(); 

    string getModule(); 
    void setModule(string); 

    bool getFulltime(); 
    void setFulltime(bool); 

    string getClassnumber(); 
    void setClassnumber(string); 
    //to create the get and set methods for all the attributes 


//attribute 
private: 
    string id; 
    string name; 
    string classcode; 
    string module; 
    bool fulltime; 
    string classnumber; 
    string attendance[10]; 
    int test1; 
    int test2; 
    int tutorial; 
    int exam; 
}; 

#endif //STUDENT_Hs 

答えて

1

あなたが言った最初のエラーから、あなたのコンパイラはケース6の中で文字列変数 'c​​ode'の作成について不平を言っているようです。 。これは、あなたが持っている最初のエラーを修正する必要があります。

「getId」と「getModule」という関数は、 'module'クラスの関数であり、 'module'クラスのインスタンスでしか呼び出せないことを示しています。しかし、それらを学生オブジェクトのベクトル上で呼び出そうとしています。

+0

最後の2つのエラーは両方ともコードを削除することで解決できます。 'id'、' module'、 'name'は使用されないので、それらを取得するコードを修正するポイントはありません。 – user4581301

0

それはswitch文の中で変数を宣言するために悪い考えです:

switch(i) { 
case 1: 
    int foo = 42; 
    doSomething(foo); 
    break; 
case 2: 
    // aargh `foo` is in scope but uninitialised if we jump to here 
    ... 
} 

switch文の外int fooを持参、またはswitchステートメント内のローカルスコープに入れてのいずれか、この問題を解決するには:

switch(i) { 
case 1: 
    { 
    int foo = 42; 
    doSomething(foo); 
    } // foo is destroyed 
    break; 
case 2: 
    // there is no foo, there is no problem 
    ... 
} 

この変更を加えて、Clangに素敵なエラーメッセージがあるので、私はあなたのコードをclang形式とオンラインのClangコンパイラに入れました。ここでクランが言っているものです。これらの

prog.cc:69:27: warning: comparison of integers of different signs: 'int' and 'size_type' (aka 'unsigned long') [-Wsign-compare] 
     for (int i = 0; i < list.size(); i++) { 
         ~^~~~~~~~~~~~ 
prog.cc:151:20: warning: ISO C++11 does not allow conversion from string literal to 'char *' [-Wwritable-strings] 
     char *ft = "FT"; 
       ^
prog.cc:243:12: warning: variable 'i' is uninitialized when used here [-Wuninitialized] 
    if (s.at(i) != 'S') { 
     ^
prog.cc:237:8: note: initialize the variable 'i' to silence this warning 
    int i; 
    ^
     = 0 
prog.cc:364:23: warning: comparison of integers of different signs: 'int' and 'size_type' (aka 'unsigned long') [-Wsign-compare] 
    for (int i = 0; i < list.size(); i++) { 
        ~^~~~~~~~~~~~ 
prog.cc:377:22: error: use of undeclared identifier 'current_module' 
    if (code.compare(current_module) == 0) { 
        ^
prog.cc:375:21: warning: comparison of integers of different signs: 'int' and 'size_type' (aka 'unsigned long') [-Wsign-compare] 
    for (int i = 0; i < students.size(); i++) { 
        ~^~~~~~~~~~~~~~~~ 
prog.cc:385:23: error: no member named 'getId' in 'std::__1::vector<Student, std::__1::allocator<Student> >' 
    string id = student.getId(); 
       ~~~~~~~^
prog.cc:386:25: error: no member named 'getName' in 'std::__1::vector<Student, std::__1::allocator<Student> >' 
    string name = student.getName(); 
       ~~~~~~~^
prog.cc:387:27: error: no member named 'getModule' in 'std::__1::vector<Student, std::__1::allocator<Student> >' 
    string module = student.getModule(); 
        ~~~~~~~^
prog.cc:393:12: error: reference to non-static member function must be called 
    if (id.compare) 
     ~~~^~~~~~~ 

    (snipped: a lot of suggestions for what you might have meant instead) 

prog.cc:394:20: error: invalid operands to binary expression ('string' (aka 'basic_string<char, char_traits<char>, allocator<char> >') and 'int') 
     (current_id) == 0 && name.compare(current_name) == 0 && 
     ~~~~~~~~~~~~^~ 
prog.cc:384:64: warning: unused parameter 's' [-Wunused-parameter] 
bool isDuplicateStudentRecord(vector<Student> student, Student s) { 
                  ^
prog.cc:388:21: warning: comparison of integers of different signs: 'int' and 'size_type' (aka 'unsigned long') [-Wsign-compare] 
    for (int i = 0; i < student.size(); i++) { 
        ~^~~~~~~~~~~~~~~ 
7 warnings and 6 errors generated. 

を、いくつかのマイナーな(しかし固定価値は、例えばfor(size_t i = 0...代わりintの)ですが、「エラー」マークのものがより重要です。コンパイラを設定してすべてのことを警告し、すべての警告を消すことは、一般的には良い習慣です。

あなたがここにオンラインクランコンパイラで(switchに余分な括弧とすべての打ち鳴らす形式LLVMスタイルで持つ)コードを見ることができます:http://melpon.org/wandbox/permlink/qLnE80Hs6FJWl9Fy

student.getID()エラーがあるため、この機能で発生:

bool isDuplicateStudentRecord(vector<Student> student, Student s) { 
    string id = student.getId(); 
    string name = student.getName(); 
    string module = student.getModule(); 
    ... 

vector<Student>にあるgetID()は、Studentには表示されません。 string id = s.getID();を意味しましたか?

+0

こんにちはジャック、私はここでいくつかの変更を加えました。エラーを調べるのを助けてください。 http://melpon.org/wandbox/permlink/qLnE80Hs6FJWl9Fy –

0

変更後。

case 6:{ 
      cout << "Enter Module Code: "; 
      string code; 
      cin >> code; 
      list = getStudentByModule(students, code); 
      for (int i=0; i < list.size(); i++){ 
       Student s = list.at(i); 
       cout << s.toString() << endl; 
      } 
      cout<<"List Student by Module Code"<<endl; 
      break; 
       } 

vector<Student> getStudentByModule(vector<Student> students,string code){ 
    vector<Student> list; 
    for (int i=0; i< students.size(); i++){ 
     Student s = students.at(i); 
     if (code.compare(current_module) == 0){ 
      list.push_back(s); 
     } 
    } 
    return list; 
} 

は以下

bool isDuplicateStudentRecord(vector<Student> student, Student s){ 
    string id = s.getId(); 
    string name = s.getName(); 
    string module = s.getModule(); 
    for(int i=0; i< student.size(); i++){ 
     Student s = student.at(i); 
     string current_id = s.getId(); 
     string current_name = s.getName(); 
     string current_module = s.getModule(); 
     if(id.compare)(current_id) == 0 && 
      name.compare(current_name) == 0 && 
      (module.compare(current_module) == 0);{ 
      return true; 
     } 

エラー表示を複製します。

1> C:プロジェクト\ Visual Studioの2010 \ \ユーザー\ cry83 \ドキュメント\ partb \ partb \ partb.cpp(378):エラーC2065: 'current_module':宣言されていない識別子

1> C:\ (C41):警告C4018: '<':符号付き/符号なし不一致

1> c:\ users \ cry83 \ documents \ visualユーザーが\ cry83 \ documents \ visualスタジオ2010 \ projects \ partb \ partb \ partb.cppスタジオ2010 \ projects \ partb \ partb \ partb.cpp(396):エラーC3867: 'std :: basic_string < _Elem、_Traits、_Ax> :: compare':関数呼び出しの引数リストがありません。使用 '&のstd :: < _Elem、_Traits、_Axを>のbasic_string ::比較' [_Elem =チャー、_Traits = STD :: char_traits、_Ax = STD ::アロケータ]

1とメンバへのポインタを作成します> partb.cpp(396):エラーC2678:バイナリ '==': 'std :: string'型の左辺オペランドを取る演算子が見つかりません(または許容される変換はありません)

1> c: (const std :: _ Exception_ptr &、const std :: _ Exception_ptr &)

(英語の場合は、次のようになります):\ program files(x86)\ microsoft visual studio 10.0 \ vc \ include \ exception

1> c:\ program files(x86)\ microsof Visual Studio 10.0 \ vc \ include \ exception(475):または 'bool std :: operator ==(std :: _ Null_type、const std :: _ Exception_ptr &)'

1> c:\ program files(x86 )\ Microsoft Visual Studio 10.0 \ vc \ include \ exception(481):または 'bool std :: operator ==(const std :: _ Exception_ptr &、std :: _ Null_type)'

1> c:\ program files (x86の)のMicrosoft Visual Studioの10.0 \ VCの\ \ \ SYSTEM_ERROR(408)を含む:または 'ブールのstd ::演算子==(CONSTのstd :: ERROR_CODE &、CONSTはstd :: error_condition &)'

1> Cを:\ program files(x86)\ microsoft visual studio 10.0 \ vc (」STDを引数リストに一致するようにしようとしているときや 'ブールのstd ::演算子==(constのはstd :: error_condition &、constのはstd :: ERROR_CODE &')

1>:\ \ SYSTEM_ERROR(416)を含み: :string、int) '

+0

私はこれをデバッグすることはできませんが、 '1> c:\ ... \ partb.cpp(378)と表示されたら:エラーC2065: 'current_module ':宣言されていない識別子'は、プログラムが知らない 'current_module'という名前のものを使っているpartb.cppの378行目を見るように指示しています。すべてのエラーと警告に対してこれを実行してください! –

+0

注目。問題を見つけることができます。ありがとうございました。 –

+0

私はcurrent_moduleのグローバル変数を行った。エラーはなくなった。しかし別のエラーが出てきた。 –

関連する問題