私はParser.h
struct を定義するを持っていますStmtParent
:
...
struct StmtParent;
class Parser {
...
次にParser.cpp
:
struct StmtParent {
int stmtNo;
int parent;
};
...
大丈夫ですか?次に、単体テスト (cppunit) があります。
# in ParserUnitTests.h
#include "header\Parser.h"
# in ParserUnitTests.cpp
void ParserUnitTests::testParseProcSideEffects() {
...
stack<StmtParent> follows;
...
次に、次のようなエラーが表示されます。
error C2027: use of undefined type 'StmtParent'
のような関数を使用できますParser::parseLine()
。構造体にアクセスできないのはなぜですか? そこで、インクルードしてみParser.h
ましたParserUnitTests.cpp
(すでにヘッダーにインクルードしていますが)。それから私は得る:
Error 8 error C2146: syntax error : missing ';' before identifier 'm_cCurToken' c:\program files (x86)\microsoft sdks\windows\v7.0a\include\parser.h 52
Error 9 error C4430: missing type specifier - int assumed. Note: C++ does not support default-int c:\program files (x86)\microsoft sdks\windows\v7.0a\include\parser.h 52
Error 10 error C4430: missing type specifier - int assumed. Note: C++ does not support default-int c:\program files (x86)\microsoft sdks\windows\v7.0a\include\parser.h 52
...