fig3.7
#include<iostream>#include<string>using namespace std;class GradeBook{public: explicit GradeBook(string name) :courseName(name) { } void setCourseName(string name) { courseName = name; } string getCourseName() const { return courseName; } void disPlayMessage() const { cout << "Welcome to the grade book for/n" << getCourseName() << "!" << endl; }PRivate: string courseName;};int main(){ GradeBook gradeBook1("cs101 Introduction to c++ programming"); GradeBook gradeBook2("cs102 Data Structures in c++"); cout << "gradeBook1 creat for course: " << gradeBook1.getCourseName() << "/ngradeBook2 creat for course: " << gradeBook2.getCourseName() << endl; system("pause"); return 0;}
新闻热点
疑难解答