error: ISO C++ forbids declaration of '' with no type
error: ISO C++ forbids declaration of '' with no type
我得到了下面的头文件error: ISO C++ forbids declaration of 'InvalidSig' with no type
,如何解决?
struct args{
InvalidSig* context; //error
string mname;
};
class InvalidSig{
.......
}
您可以在上面转发声明class InvalidSig
:
class InvalidSig;
struct args {
InvalidSig* context;
// ...
};
如果您只想在定义前使用一次名称,您也可以这样做:
struct args {
class InvalidSig* context;
// ...
};
尽管如此,我还是建议避免使用后者,因为前者更常见并且不会让阅读您代码的任何人感到困惑。
我得到了下面的头文件error: ISO C++ forbids declaration of 'InvalidSig' with no type
,如何解决?
struct args{
InvalidSig* context; //error
string mname;
};
class InvalidSig{
.......
}
您可以在上面转发声明class InvalidSig
:
class InvalidSig;
struct args {
InvalidSig* context;
// ...
};
如果您只想在定义前使用一次名称,您也可以这样做:
struct args {
class InvalidSig* context;
// ...
};
尽管如此,我还是建议避免使用后者,因为前者更常见并且不会让阅读您代码的任何人感到困惑。