Trying to use class files, getting "undefined reference to `WinMain@16'" error

I am building an application that calculates travel time necessary to reach a user selected destination from predetermined city based upon an estimated travel speed determined by the user. For this program I am to utilize classes/class source files. When compiling my source file I continuously get the error “undefined reference to `WinMain@16’” and due to my being unfamiliar with the usage of source files I am not sure how to fix this issue. Any help would be appreciated with regard to pointing me in the right direction as to properly utilizing source files. Thanks in advance for the help.

Header file:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
#include <iostream>

using namespace std;

class Trip
{
    private:
        string destination;
        double distance;

    public:
        void TripValue(string b, double c);
        void TripTime(Trip *a);
};


Source file:

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
#include "Trip.h"
#include <iostream>

using namespace std;

void Trip::TripValue(string b, double c)
{
    destination = b;
    distance = c;
}

void Trip::TripTime(Trip *a)
{
    double user_speed;
    double time;

    cout << "Please enter your estimated travel speed in miles per hour: ";
    cin >> user_speed;
    cout << endl;

    time = (a->distance / user_speed);

    cout << endl;
    cout << "Your estimated travel time to " << a->destination << " is "
        << time << " hours.\n";
    cout << endl;
}


Application code:

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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
#include <iostream>
#include "Trip.h"

using namespace std;

int main()
{
    Trip StL, Indy, Det, Nash, Dal, Den, NY, LA, Mia, Sea;

    int choice;

    StL.TripValue("St. Louis", 297.34);
    Indy.TripValue("Indianapolis", 184.78);
    Det.TripValue("Detroit", 282.73);
    Nash.TripValue("Nashville", 441.02);
    Dal.TripValue("Dallas", 925.91);
    Den.TripValue("Denver", 1004.93);
    NY.TripValue("New York", 791.50);
    LA.TripValue("Los Angeles", 2017.74);
    Mia.TripValue("Miami", 1363.55);
    Sea.TripValue("Seattle", 2032.31);

    do
    {
        cout << "=================================Trip Calulator=================================\n";
        cout << "Select your destination from Chicago:\n";
        cout << endl;
        cout << " 1. St. Louis\n";
        cout << " 2. Indianapolis\n";
        cout << " 3. Detroit\n";
        cout << " 4. Nashville\n";
        cout << " 5. Dallas\n";
        cout << " 6. Denver\n";
        cout << " 7. New York\n";
        cout << " 8. Los Angeles\n";
        cout << " 9. Miami\n";
        cout << "10. Seattle\n";
        cout << endl;
        cout << " 0. Exit\n";
        cout << "================================================================================\n";

        cin >> choice;

        cout << endl;

        switch (choice)
        {
            case 1:
                StL.TripTime(&StL);
                break;
            case 2:
                Indy.TripTime(&Indy);
                break;
            case 3:
                Det.TripTime(&Det);
                break;
            case 4:
                Nash.TripTime(&Nash);
                break;
            case 5:
                Dal.TripTime(&Dal);
                break;
            case 6:
                Den.TripTime(&Den);
                break;
            case 7:
                NY.TripTime(&NY);
                break;
            case 8:
                LA.TripTime(&LA);
                break;
            case 9:
                Mia.TripTime(&Mia);
                break;
            case 10:
                Sea.TripTime(&Sea);
                break;
        }
    } while (choice != 0);
}


You have your project set up to be a WinAPI program, which takes WinMain as the entry point instead of the more traditional main. You'll need to either change your project settings, or you'll need to create a new project (be sure to select "Console Application" as the program type -- and check the "empty solution" box)
I see, thanks for the advice.
Topic archived. No new replies allowed.