Undefined reference to `WinMain error when trying to compile C++ code

  c++

I’m learning about OOP in C++ and have been tasked with making a simple program to calculate a worker’s wages after taxes/insurance/etc, but I keep getting an undefined reference to `WinMain
‘ collect2.exe: error: ld returned 1 exit status, and I know it’s not the compiler because it did a Hello World program just fine. Here’s the code, it’s 99.9% something dumb but I’ve been reading it for 2 days and haven’t found a solution:

  #include <iostream>
using namespace std;

//Create a Trabajador class
class Trabajador 
{
    private : 
    int sueldo_base;
    double horas_extras, impuestos, prevision, salud;
    public:
    Trabajador(int sueldo_base, double horas_extras, double impuestos,
     double prevision, double salud){
        this->sueldo_base = sueldo_base;
        this->horas_extras = horas_extras;
        this->impuestos = impuestos;
        this->prevision = prevision;
        this->salud = salud;
    };

//main containing the numbers needed to calculate a month's wages
    int main() {

        cout << 100000+10*10000-(100000+10*10000)*0.19-(100000+10*10000)*0.11-(100000+10*10000)*0.07 <<endl;
        Trabajador trab(100000, 10, 0.19, 0.11, 0.07);
        cout << trab.sueldo() <<endl;
        return 0;
    }

    double sueldo();

};


double Trabajador::sueldo() {
    double sueldo, hextras, imp, prev, salud;
    hextras = this->horas_extras*10000;
    imp = (this->sueldo_base+hextras)*this->impuestos;

    prev = (this->sueldo_base+hextras)*this->prevision;

    salud = (this->sueldo_base+hextras)*this->salud;

    sueldo = this->sueldo_base + hextras - imp - prev - salud;
    return sueldo;
}

Any help is appreciated.

Source: Windows Questions C++

LEAVE A COMMENT