I was writing an interpreter in C, but the complexity was too high. I started put the code into cpp classes and I get an error:
#ifdef _TOKEN_H
#define _TOKEN_H
enum TOKEN_TYPE {INTEGER, IDENTIFIER, KEYWORD, OPERATOR, UNKNOWN};
class Token
{
public:
Token(string v = "", TOKEN_TYPE t = UNKNOWN);
private:
string value;
TOKEN_TYPE type;
};
#endif
And the Token.cpp
#include "Token.h"
using namespace std;
Token::Token(string v, TOKEN_TYPE t)
{
value = v;
type = t;
}
Use of undeclared identifier 'Token'
Anyone can help me?
Your header guard is incorrect. It should read:
Also, tokens beginning with an underscore and capital letter are reserved for any use by the implementation. So it should be:
Or even
#ifndef TOKEN_H_GUARD