Linking Error in Microsoft Visual Studio 2012 express:

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:

// Exercise 3.11 Solution: ex03_11.cpp
// Test program for modified GradeBook class.
#include

include "GradeBook.h"

using namespace std;

// function main begins program execution
int main()
{
// create a GradeBook object; pass a course name and instructor name
GradeBook gradeBook(
"CS101 Introduction to C++ Programming", "Professor Smith" );

// display initial value of instructorName of GradeBook object
cout << "gradeBook instructor name is: "
<< gradeBook.getInstructorName() << "\n\n";

// modify the instructorName using set function
gradeBook.setInstructorName( "Assistant Professor Bates" );

// display new value of instructorName
cout << "new gradeBook instructor name is: "
<< gradeBook.getInstructorName() << "\n\n";

// display welcome message and instructor's name
gradeBook.displayMessage();
} // end main

// Exercise 3.11 Solution: GradeBook.cpp
// Member-function definitions for class GradeBook.
#include

include "GradeBook.h"

using namespace std;

// constructor initializes courseName and instructorName
// with strings supplied as arguments
GradeBook::GradeBook( string course, string instructor )
{
setCourseName( course ); // initializes courseName
setInstructorName( instructor ); // initialiZes instructorName
} // end GradeBook constructor

// function to set the course name
void GradeBook::setCourseName( string name )
{
courseName = name; // store the course name
} // end function setCourseName

// function to retrieve the course name
string GradeBook::getCourseName()
{
return courseName;
} // end function getCourseName

// function to set the instructor name
void GradeBook::setInstructorName( string name )
{
instructorName = name; // store the instructor name
} // end function setInstructorName

// function to retrieve the instructor name
string GradeBook::getInstructorName()
{
return instructorName;
} // end function getInstructorName

// display a welcome message and the instructor's name
void GradeBook::displayMessage()
{
// display a welcome message containing the course name
cout << "Welcome to the grade book for\n" << getCourseName() << "!"
<< endl;

// display the instructor's name
cout << "This course is presented by: " << getInstructorName() << endl;
} // end function displayMessage

/**************************************************************************
* (C) Copyright 1992-2010 by Deitel & Associates, Inc. and *
* Pearson Education, Inc. All Rights Reserved. *
* *
* DISCLAIMER: The authors and publisher of this book have used their *
* best efforts in preparing the book. These efforts include the *
* development, research, and testing of the theories and programs *
* to determine their effectiveness. The authors and publisher make *
* no warranty of any kind, expressed or implied, with regard to these *
* programs or to the documentation contained in these books. The authors *
* and publisher shall not be liable in any event for incidental or *
* consequential damages in connection with, or arising out of, the *
* furnishing, performance, or use of these programs. *
**************************************************************************/

// Exercise 3.11 Solution: GradeBook.h
// Definition of GradeBook class that stores an instructor's name.
#include // program uses C++ standard string class
using namespace std;

// GradeBook class definition
class GradeBook
{
public:
// constructor initializes course name and instructor name
GradeBook( string, string );
void setCourseName( string ); // function to set the course name
string getCourseName(); // function to retrieve the course name
void setInstructorName( string ); // function to set instructor name
string getInstructorName(); // function to retrieve instructor name
void displayMessage(); // display welcome message and instructor name
private:
string courseName; // course name for this GradeBook
string instructorName; // instructor name for this GradeBook
}; // end class GradeBook

/**************************************************************************
* (C) Copyright 1992-2010 by Deitel & Associates, Inc. and *
* Pearson Education, Inc. All Rights Reserved. *
* *
* DISCLAIMER: The authors and publisher of this book have used their *
* best efforts in preparing the book. These efforts include the *
* development, research, and testing of the theories and programs *
* to determine their effectiveness. The authors and publisher make *
* no warranty of any kind, expressed or implied, with regard to these *
* programs or to the documentation contained in these books. The authors *
* and publisher shall not be liable in any event for incidental or *
* consequential damages in connection with, or arising out of, the *
* furnishing, performance, or use of these programs. *
**************************************************************************/

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 >,class std::basic_string<char,struct>,class std::allocator >)" (??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 >)" (?setInstructorName@GradeBook@@QAEXV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@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 > __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

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories