• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 342
  • Last Modified:

Error duing compilation

Hi guys: Can any one please tell me what does this error means ?


Compiler: Default compiler
Executing  g++.exe...
g++.exe "C:\Documents and Settings\Kathy\My Documents\test.cpp" -o "C:\Documents and Settings\Kathy\My Documents\test.exe"    -I"C:\Dev-Cpp\lib\gcc\mingw32\3.4.2\include"  -I"C:\Dev-Cpp\include\c++\3.4.2\backward"  -I"C:\Dev-Cpp\include\c++\3.4.2\mingw32"  -I"C:\Dev-Cpp\include\c++\3.4.2"  -I"C:\Dev-Cpp\include"   -L"C:\Dev-Cpp\lib"
C:\Dev-Cpp\lib/libmingw32.a(main.o)(.text+0x106):main.c: undefined reference to `WinMain@16'
collect2: ld returned 1 exit status

Execution terminated
-----------------------------------------------------------------------

#include<string>
using namespace test;

class Employee
      {
      public:
             Employee();
             Employee(string, double);
             void setEmployee(string, double);
             double getSalary();
             string getName();
             void calcNewSalary(double);
      private:
              string name;
              double salary;
      };
      Employee::Employee()
             {
             name = "";
             salary = 0.0;
             }
      Employee::Employee(string n, double s)
             {
             name = n;
             salary = s;
             }
      void Employee::setEmployee(string n, double s)
             {
             name = n;
             salary = s;
             }
      double Employee::getSalary()
             {
             return salary;
             }
      string Employee::getName()
             {
             return name;
             }
      void Employee::calcNewSalary(double r)
             {
             if(r >=0.0)
                   salary = salary * r + salary;
             else
                    salary = 0.0;
             }
0
mustish1
Asked:
mustish1
2 Solutions
 
mrjoltcolaCommented:
Your program has no main() function. It must for C++ if you expect a complete .exe

Since you used -o test.exe it wants a complete program.

If you wanted to compile your class just into a single object file, you could use -c test.o but that likely isn't what you want to accomplish here.
0
 
käµfm³d 👽Commented:
Hey!!  That's not C#   = )

It sounds like you're trying to compile this as a standalone executable, but you haven't defined a Main method. This appears to be just a class file, so I don't see why you would be trying to make an executable out of it.
0
 
mustish1Author Commented:
Im sorry i forgett main.

#include<string>
#include<iostream>
using namespace test;
class Employee
      {
      public:
             Employee();
             Employee(string, double);
             void setEmployee(string, double);
             double getSalary();
             string getName();
             void calcNewSalary(double);
      private:
              string name;
              double salary;
      };
      Employee::Employee()
             {
             name = "";
             salary = 0.0;
             }
      Employee::Employee(string n, double s)
             {
             name = n;
             salary = s;
             }
      void Employee::setEmployee(string n, double s)
             {
             name = n;
             salary = s;
             }
      double Employee::getSalary()
             {
             return salary;
             }
      string Employee::getName()
             {
             return name;
             }
      void Employee::calcNewSalary(double r)
             {
             if(r >=0.0)
                   salary = salary * r + salary;
             else
                    salary = 0.0;
             }
int main()
{
    Employee myEmployee;
    string name = "";
    double pay = 0;
    double rate = 0.0;
    cout << "Employee's name:";
    getline(cin, name);
    cout << "Employee's current salary:";
    cin >> pay;
    cin.ignore(100, '\n');
    cout << "Raise rate:";
    cin >> rate;
    cin.ignore(100, '\n');
    myEmployee.setEmployee(name, pay);
    cout << "Name:" << myEmployee.getName() << endl;
    cout << "Current salary: $" << myEmployee.getSalary() << endl;
    myEmployee.calcNewSalary(rate);
    cout << "New salary: $" << myEmployee.getSalary() << endl;
    system("pause");
    return 0;
}
0

Featured Post

Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now