如何在没有与“无效使用不完整类型”相关的麻烦的情况下实现以下内容?
class A { // line#10
/*(...) some fields and methods here. */
// more fields of the following functionality exist, storing data about object A's state.
int SomeField;
class Exception {
/*(...) some fields and methods here. */
public: enum ProblemCase { /*(...) */ };
protected: Exception( ProblemCase issue, int additionalData ) { /*(...)*/ } // line#29
friend Exception A::BuildException( ProblemCase ); // line#34
};
inline Exception BuildException( Exception::ProblemCase issue ) {
return Exception( issue, SomeField ); // line#99
}
};
更新:错误日志:
A.hpp:34:72: error: invalid use of incomplete type ‘class A’
A.hpp:10:7: error: forward declaration of ‘class A’
A.hpp: In member function ‘A::Exception A::BuildException(A::Exception::ProblemCase)’:
A.hpp:29:20: error: ‘A::Exception::Exception(A::Exception::ProblemCase, int)’ is protected
A.hpp:99:46: error: within this context
请注意,名称已更改,因此错误日志中的字符数不正确。