class separate interface from implement.

3 errors on client code
undefined reference to GradeBook::GradeBook( std::string name )

can you please tell me where is the problem?

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
// GradeBook.h class definition

#include <string>


class GradeBook
{
public:
    GradeBook( std::string ); // course name constructor
    void setCourseName ( std::string ); // function that sets the course name
    std::string getCourseName(); // string that gets the course name
    void displayMessage();
private:
    std::string courseName;
};



1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
// GradeBook.cpp
#include <iostream>
#include "GradeBook.h"

GradeBook::GradeBook( std::string name )
{
    setCourseName( name );
}

void GradeBook::setCourseName( std::string name)
{
    courseName = name;
}

std::string GradeBook::getCourseName()
{
    return courseName;
}

void GradeBook::displayMessage()
{
    std::cout << "Welcome to the course " << getCourseName() << "!" << std::endl;
}


client code
1
2
3
4
5
6
7
8
9
10
11
#include <iostream>
#include "GradeBook.h"

int main()
{
    GradeBook gradeBook1("Grade book 1 data");
    GradeBook gradebook2("Grade book 2 data");

    std::cout << "Gradebook 1 " << gradeBook1.getCourseName() << std::endl;
}
Topic archived. No new replies allowed.