I defined two header files.
global.h
#ifndef GLOBAL_H
#define GLOBAL_H
#include <queue>
#include <string>
//#include "token.h"
class Token;
typedef std::string TokenValue;
enum TokenType{//...};
inline void clear(std::queue<Token> tokens)
{
std::queue<Token> empty;
std::swap(tokens, empty);
}
#endif // GLOBAL_H
and token.h
#ifndef TOKEN_H
#define TOKEN_H
#include "global.h"
class Token
{
public:
Token (TokenType token_type, TokenValue token_value)
{
token_type_ = token_type;
token_value_ = token_value;
}
~Token (){}
//...
private:
TokenType token_type_;
TokenValue token_value_;
};
I use foward declaration in global.h, but i don't use the reference or pointer of class Token. I use std::queue<Token> empty;
in global.h. I think this statement must need the size of Token. I can't figure out why it can compiles success. It's the problem of queue
?