test problem...undefined main

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
// Fig. 3.3: fig03_03.cpp
// Define class GradeBook with a member function that takes a parameter;
// Create a GradeBook object and call its displayMessage function.
#include <iostream>
#include <string> // program uses C++ standard string class
using namespace std;

// GradeBook class definition
class GradeBook
{
public:
   // function that displays a welcome message to the GradeBook user 
   void displayMessage( string courseName )
   {
      cout << "Welcome to the grade book for\n" << courseName << "!" 
         << endl;
   } // end function displayMessage
}; // end class GradeBook  

// function main begins program execution
int main()
{
   string nameOfCourse; // string of characters to store the course name
   GradeBook myGradeBook; // create a GradeBook object named myGradeBook
   
   // prompt for and input course name
   cout << "Please enter the course name:" << endl;
   getline( cin, nameOfCourse ); // read a course name with blanks
   cout << endl; // output a blank line

   // call myGradeBook's displayMessage function
   // and pass nameOfCourse as an argument
   myGradeBook.displayMessage( nameOfCourse );
} // end main 


Why is this not working. it gave me error undefined reference to 'main'
Last edited on
Wild shot in the dark here, change line 5 to #include <string>
closed account (S6k9GNh0)
http://ideone.com/SmjVx

Not sure, seems to be a problem in your toolchain.
it was originally <string> but i changed it to <cstring> , and forgot to change it back before posting,
what is a toolchain?
ok i figured it out...i had to update code blocks
Topic archived. No new replies allowed.