不完整类型不允许出错

时间:2017-07-09 09:17:46

标签: c++

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;
}

1 个答案:

答案 0 :(得分:0)

;之后删除class Gradebook,一切都会好的。