Problem with Multiple definitions

Hello all!

Im trying to have a simple function yet getting the error:

multiple definition of `Assistant::getType(std::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::basic_string<char, std::char_traits<char>, std::allocator<char> >)'


Ive changed it as much as I can looking for a fix but havent found any, here is my 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
/* 
 * File:   main.cpp
 * Author: purefan
 *
 * Created on March 12, 2010, 7:45 PM
 */

#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <iostream>
#ifndef _MAIN_CPP
#define _MAIN_CPP
#endif
#ifndef _DIRECTOR_H
#include "Director.h"
#endif


using namespace std;

class Assistant
{
public:
    string getType(std::string, std::string);    
};

std::string Assistant::getType(string sFull, string sToken)
{
        string sOut = "";
        if (sFull.find(sToken) != string::npos)
        {
            sFull.replace(0,sToken.length(),"");
            return sFull;
        }
        return sOut;

}
int main(int argc, char** argv)
{
    // check parameters
    string sFile = "";
    int iGamesToParse = 0;
    Assistant oA;
    for (int i=1;i<argc;i++)
    {
        string sFull = std::string(argv[i]);
        if (sFull.find("file=") != string::npos)
            sFile = oA.getType(sFull, "file=");

        if (sFull.find("games=") != string::npos)
        {
            string sTemp = oA.getType(sFull, "games=");
            iGamesToParse = atoi(sTemp.c_str());
        }
    }

    if (sFile == "" || iGamesToParse == 0)
    { // an error occured
        cout << "Error: parameters missing. example: games=32 file=file.txt" << endl;
    }
    else
    {
       
    }
    
    return (EXIT_SUCCESS);
}



Any help please?
What other source files do you have?
a Director.cpp, top part looks like this:
1
2
3
#ifndef _DIRECTOR_H
#include "Director.h"
#endif 


and a Director.h, top part looks like this
1
2
3
4
5
6
7
#ifndef _MAIN_CPP
#include "main.cpp"
#endif

#ifndef _DIRECTOR_H
#define	_DIRECTOR_H
- Typically you put include guards in the header, not around the #include statement.

- Never #include cpp files.

- there's no need to include guard cpp files because they're not included (or at least they shouldn't be)


Obligatory link: http://www.cplusplus.com/forum/articles/10627/ (see section 4)
Reading the link right now, thanks Disch
Topic archived. No new replies allowed.