Okay have had a quick look. Looks like you are missing a constructor:-
Code:
int main()
{
GradeBook gradeBook1 ("CSO1 Introduction to C++ Programming", "Mona Cherri");
This needs the following constructor:-
In gradeBook.h:-
Code:
public:
GradeBook( const & string, const & string ) ; // consructed with course and instructor name.
In gradeBook.cpp
Code:
GradeBook::GradeBook( const string & course_name, const string & instructor_name )
: courseName( course_name ), instructorName( instructor_name ), yesName( "" )
{
}
Your code is okay but it is best to initialise class members in the above way. Also, I've used references to const strings as the parameters. It's a good idea to pass by reference rather than by value whenever possible. This avoids unnecessary copies. The const bit is there to enforce the requirement that the constructor/method should not alter the value of the variable (which it could since it is passed as a parameter by reference).
Also, if you end up using lots of things in std and many files, you're going to get sick of typing using std::xxx, so just use
One final point, it's common practise in C++ to distinguish between class member variables and temporary variables in code. For example I would rename your Gradebook members like this:-
Code:
private:
string course_name_ ; // course name for this GradeBook
string instructor_name_ ;
string yes_name_ ;
This has a couple of benefits:- when you look at your code it's easy to check that you are modifying a member value (rather than a local variable), secondly, it avoids having to juggle parameter names in methods when you want to set a member value. Here's an example of what I mean:-
Code:
GradeBook::GradeBook( const string & course_name, const string & instructor_name )
: course_name_( course_name ), instructor_name_( instructor_name ), yes_name_( "" )
{
}
If you don't like using _ there are other popular schemes one of which is using an 'm' before the variable name, eg mCourseName, mInstructorName etc.
b e n