-4
Here is my code
#include<iostream>
#include<string>
using namespace std;
class GradeBook; // GradeBook class definition
{
public:
// constructor initializes courseName
GradeBook(string name)
{
setCourseName(name);
}
void setCourseName(string name)
{
courseName = name;
}
string getCourseName()
{
return courseName;
}
void displayMessage()
{
cout << "Welcome to the grade book for\n" << getCourseName() << "!" << endl;
}
private:
string courseName;
};
int main()
{
GradeBook gradeBook1("CS101 Introduction to C++ Programming");
GradeBook gradeBook2("Visual C++ introduction");
cout << "gradeBook1 created for course: " << gradeBook1.getCourseName()
<< "\ngradeBook2 created for course: " << gradeBook2.getCourseName()
<< endl;
return 0;
}
錯誤可能是由簡單的錯字造成的:'class GradeBook;'。後面的';'使得「不完整」類型在這裏是錯誤的。請刪除它。 – Scheff
從頭閱讀錯誤列表,而不是結束。 – LogicStuff