我有以下文件:
CP.h
#ifndef CP_H_
#define CP_H_
class CP {
public:
enum Cardinalite {VIDE = '\0', PTINT = '?', AST = '*', PLUS = '+'};
CP(Cardinalite myCard);
virtual ~CP();
private:
Cardinalite card;
};
#endif /* CP_H_ */
和dtd.y
%{
using namespace std;
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include "AnalyseurDTD/DtdDocument.h"
#include "AnalyseurDTD/CP.h"
void yyerror(char *msg);
int yywrap(void);
int yylex(void);
DtdDocument * doc = new DtdDocument();
%}
%union {
char *s;
DtdElement * dtdelt;
CP *cpt;
CP::Cardinalite card;
}
以及以下奇怪的错误:
AnalyseurDTD/dtd.y:20:2: error: ‘CP’ does not name a type
AnalyseurDTD/dtd.y:21:2: error: ‘CP’ does not name a type
奇怪的是,如果我把 CP *cpt; 在 DtdDocument * doc = new DtdDocument() 之后;我没有错误:/