I'm referring to this stackoverflow post:
When I build the following code, I get: "duplicate symbol for architecture x86_64". I've been googling for the past couple of hours, but have not found anything to help. Any suggestions?
#ifndef __lexer__lexer__
#define __lexer__lexer__
#include <stdio.h>
#include <string>
namespace Tag{
const int AND = -1,
OR = -2;
}
class Token{
public:
std::string Name;
std::string Type;
std::string Value;
int Tag;
Token(std::string name, std::string type, std::string value, int tag){
Name = name;
Type = type;
Value = value;
Tag = tag;
}
};
class Word : public Token{
public:
Word(std::string name, std::string type, std::string value, int tag) : Token(name, type, value, tag){}
static const Word AND;
};
const Word Word::AND = *new Word("and", "logical", "&&", Tag::AND);
#endif /* defined(__lexer__lexer__) */
The code:
const Word Word::AND = *new Word("and", "logical", "&&", Tag::AND);
Is what is giving me the problems.