Every time I write a code using Visual Studio for my C++ class, I keep getting reference linking errors and I dont know how to fix it. I have attached the code and the error that I keep getting.
// Fig. 3.7: fig03_07.cpp 47
// Instantiating multiple objects of the GradeBook class and using
// the GradeBook constructor to specify the course name
// when each GradeBook object is created.
#include <iostream>
using std::cout;
using std::endl;
#include <string> // program uses C++ standard string class
using std::string;
// GradeBook class definition
class GradeBook
{
public:
// constructor initializes courseName with string supplied as argument
GradeBook( string name )
{
setCourseName( name ); // call set function to initialize courseName
} // end GradeBook constructor
// function to set the course name
void setCourseName( string name )
{
courseName = name; // store the course name in the object
} // end function setCourseName
// function to get the course name 48
string getCourseName()
{
return courseName; // return object's courseName
} // end function getCourseName
// display a welcome message to the GradeBook user
void displayMessage()
{
// call getCourseName to get the courseName
cout << "Welcome to the grade book for\n" << getCourseName()
<< "!" << endl;
} // end function displayMessage
private:
string courseName; // course name for this GradeBook
}; // end class GradeBook
Errors I keep getting:
1>------ Build started: Project: class example2, Configuration: Debug Win32 ------
1>Linking...
1>MSVCRTD.lib(crtexe.obj) : error LNK2019: unresolved external symbol _main referenced in function ___tmainCRTStartup
1>C:\Documents and Settings\dj000034880\Desktop\Computer Science 2\class example2\Debug\class example2.exe : fatal error LNK1120: 1 unresolved externals
1>Build log was saved at "file://c:\Documents and Settings\dj000034880\Desktop\Computer Science 2\class example2\class example2\Debug\BuildLog.htm"
1>class example2 - 2 error(s), 0 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========