Undefined reference to ...
I think I declared and implemented the class 'GradeBook' in 'GradeBook.h' and 'GradeBook.cpp' files respectively. I also put the files in the same folder with the main.cpp file. However, I get the the errors 1) 'undefined reference to 'GradeBook::GradeBook(std::string)'. 2)'undefined reference to 'GradeBook::displayMessage()' where displayMessage is a public member function. My Header and Source Files of the class are as follows Header File: #include <iostream> #include <string> using namespace std; class GradeBook { public: GradeBook(string name); void setCourseName(string name); string getCourseName(); void displayMessage(); private: string courseName; }; Source Code: #include <iostream> #include <string> #include "GradeBook.h" using namespace std; GradeBook::GradeBook(string name) { courseName = name; } GradeBook::setCourseName(string name) { if (name.length() <= 25) courseName = name; if (name.length() > 25) { courseName = name.substr(0,25); cout << "Name" << name << "exceeds 25 character.\n" << "Limiting course name to first 25 characters.\n" } } GradeBook::getCourseName() { return courseName; } GradeBook::displayMessage() { cout << "Welcome to grade book for\n" << getCourseName() << endl; } Test Code: #include <iostream> #include <string> #include "GradeBook.h" using namespace std; int main() { string name = "Default Name"; GradeBook gradeBook1(name); gradeBook1.displayMessage(); } I use CodeBlocks IDE to compile the code. Is there anyone who knows what is my mistake.!