OOPS Problem when i separating interface from implimentation

The main file is untitled1.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#include <iostream>
#include <string>
#include "PaySystem.h"
using namespace std;
int main()
{
    string EmployeeType; //12 scales 14 and 16 scales
    cout<<"Please Enter Emplyee Types ";
    getline (cin,EmployeeType);
    PaySystem MyPaymentSystem("Good To Use");
    MyPaymentSystem.employeeTypeSet(EmployeeType);
    MyPaymentSystem.displayMsg();
    
    
    
    


    cout<<endl<<endl;
    system ("PAUSE");
}

This Class Header file is PaySystem.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
#include <vector>
#include <string>
#include <iostream>
#include <sstream>
#include <fstream>
#include <cctype>
#include<MyFunctions.h>
using namespace std;
class PaySystem
{
      public:
             PaySystem(string name);
             void employeeTypeSet(string empl);
             string employeeTypeGet();
             void displayMsg();
            
      private:
              string EmployeeType;
};

The CPP file is PaySystem.cpp
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
#include <iostream>
#include <string>
#include "PaySystem.h" 
using namespace std;
PaySystem::PaySystem(string name)
             {
                   employeeTypeSet(name);
                        }
             void PaySystem::employeeTypeSet(string empl)
             {
                  EmployeeType = empl;
                  }
             string PaySystem::employeeTypeGet()
             {
                    return EmployeeType;
                    }
             void PaySystem::displayMsg()
             {
                         cout<<"\n\n----------Welcome-----------\n\n\n"
                         <<" Syes's Pay System For \n\n"
                         <<" "<<employeeTypeGet()
                         <<"\n\n"
                         <<" You can calculate Saleries Through This System ";
                         }
                         
                         


The Problem i face when i compile the PaySystem.cpp is
[Linker error] undefined reference to `WinMain@16'
ld returned 1 exit status
The Problem i face when i compile the untitled1.cpp is
[Linker error] undefined reference to `PaySystem::PaySystem(std::string)'
[Linker error] undefined reference to `PaySystem::employeeTypeSet(std::string)'
[Linker error] undefined reference to `PaySystem::displayMsg()'
ld returned 1 exit status

please help
Last edited on
Are you trying to compile the files separately?
Yes i am trying to compile the files separetly . if this is wrong then how can i compile them jointly ? i am using dev c++
[Linker error] undefined reference to `WinMain@16'
You're using Windows and your project is configured as a Windows application. You need to go to the linker settings (somewhere) and change it to a Console application.

[Linker error] undefined reference to `PaySystem::PaySystem(std::string)' ...
You need to add all three files to your project. The two .cpp files will be compiled and linked along with the C and C++ runtime libraries to give you a console application.
Please help me how to resolve this

  [Linker error] undefined reference to `WinMain@16' 


I am using Dev C++
try this

goto project --> project settings and there you can chage it to console application.
Huh!! Now i am confirm that It was because of system ("PAUSE"); at the end of main function. when i remove this line the error eliminated automatically.

can any one tell me why this error was because of system ("PAUSE");
the following code is missing :#include<MyFunctions.h>
my English is very bad ... use google translator.
why they say a picture is worth a thousand words.
the solution there.
http://subefotos.com/ver/?38a76df0ed98cf6fc74936d341c412e3o.jpg
http://subefotos.com/ver/?0ff7d7e51dcbab94efc878f135da5213o.jpg
http://subefotos.com/ver/?31e2c8aa33af7b7c04b52afdc824000do.jpg
http://subefotos.com/ver/?e53b21fdc352d508f3016239d631fc5ao.jpg
allĂ­ la respuesta y como mejorar el codigo
Last edited on
Topic archived. No new replies allowed.