I have three files, one is an interface, main file and the header file. I am using visual studio 2012 express. Below is the code:
#include <iostream>
#include "GradeBook.h"
using namespace std;
int main()
{
GradeBook gradeBook(
"CS101 Introduction to C++ Programming", "Professor Smith" );
cout << "gradeBook instructor name is: "
<< gradeBook.getInstructorName() << "\n\n";
gradeBook.setInstructorName( "Assistant Professor Bates" );
cout << "new gradeBook instructor name is: "
<< gradeBook.getInstructorName() << "\n\n";
gradeBook.displayMessage();
}
#include <iostream>
#include "GradeBook.h"
using namespace std;
GradeBook::GradeBook( string course, string instructor )
{
setCourseName( course ); setInstructorName( instructor ); }
void GradeBook::setCourseName( string name )
{
courseName = name; }
string GradeBook::getCourseName()
{
return courseName;
}
void GradeBook::setInstructorName( string name )
{
instructorName = name; }
string GradeBook::getInstructorName()
{
return instructorName;
}
void GradeBook::displayMessage()
{
cout << "Welcome to the grade book for\n" << getCourseName() << "!"
<< endl;
cout << "This course is presented by: " << getInstructorName() << endl;
}
#include <string> // program uses C++ standard string class
using namespace std;
class GradeBook
{
public:
GradeBook( string, string );
void setCourseName( string ); string getCourseName(); void setInstructorName( string ); string getInstructorName(); void displayMessage(); private:
string courseName; string instructorName; };
I get the following errors:
Error 1 error LNK2019: unresolved external symbol "public: __thiscall GradeBook::GradeBook(class std::basic_string<char,struct>,class std::allocator<char> >,class std::basic_string<char,struct>,class std::allocator<char> >)" (??0GradeBook@@QAE@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@0@Z) referenced in function _wmain c:\Users\Leetop\documents\visual studio 2012\Projects\ex311\ex311\ex311.obj ex311
Error 2 error LNK2019: unresolved external symbol "public: void __thiscall GradeBook::setInstructorName(class std::basic_string<char,struct>,class std::allocator<char> >)" (?setInstructorName@GradeBook@@QAEXV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@Z) referenced in function _wmain c:\Users\Leetop\documents\visual studio 2012\Projects\ex311\ex311\ex311.obj ex311
Error 3 error LNK2019: unresolved external symbol "public: class std::basic_string<char,struct>,class std::allocator<char> > __thiscall GradeBook::getInstructorName(void)" (?getInstructorName@GradeBook@@QAE?AV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@XZ) referenced in function _wmain c:\Users\Leetop\documents\visual studio 2012\Projects\ex311\ex311\ex311.obj ex311
Error 4 error LNK2019: unresolved external symbol "public: void __thiscall GradeBook::displayMessage(void)" (?displayMessage@GradeBook@@QAEXXZ) referenced in function _wmain c:\Users\Leetop\documents\visual studio 2012\Projects\ex311\ex311\ex311.obj ex311
Error 5 error LNK1120: 4 unresolved externals c:\users\leetop\documents\visual studio 2012\Projects\ex311\Debug\ex311.exe 1 1 ex311