undefined reference to WinMain@16

I am using a header file and a cpp file on codeblocks, and it seems the codes looks fine, but when I try to run the program, it said undefined reference to WimMain@16, and I have no idea what that means.. I am new to programming so could anyone help me please? Thank you!


1
2
3
4
5
6
7
8
9
10
11
12
13
14
#include <string>
using namespace std;

class Gradebook
{
public:
    Gradebook (string);
    void setCourseName (string);
    string getCourseName();
    void display();
    void determineClassAverage();
private:
    string courseName;
};







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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#include <iostream>
#include "header_if_an_else_if.h"

using namespace std;


Gradebook::Gradebook (string name)
{
    setCourseName(name);
}

void Gradebook::setCourseName(string name)
{
    if (name.length()<=25)
        courseName=name;
    else
    {
        courseName = name.substr (0,25);
        cout << "Name"<< name<< " Exceed the maximum length";

    }
}

string Gradebook::getCourseName()
{
    return courseName;
}

void Gradebook::display()
{
    cout << "welcome to the grade book for "<< getCourseName();

}

void Gradebook::determineClassAverage()
{
    int total, gradeCounter, grade, average;

    total=0;
    gradeCounter=1;

    while (gradeCounter <=10)
    {
        cout << "enter grade: ";
        cin >> grade;
        total = total +grade;
        gradeCounter = gradeCounter +1;
    }
        average = total/10;

        cout << "\n Total of all 10 grades is "<< total<< endl;
        cout << "Class average is "<< average<< endl;

}
You have no main function ;)
Congrats XD
Forgetting the very first thing every programmer should learn.

(Just confirming that the missing main() is the cause of the error btw).
Oh I got it, thanks guys! x)
Also.... you have your project set up to be a WinAPI program instead of a console program... so it's actually looking for WinMain rather than main. So even if you add main, you might still get this error.

In addition to adding main, you need to go in your project settings and change the program to be built as a console program.
Topic archived. No new replies allowed.