[英]C++ Struct and “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
以下头文件的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;
// ...
};
但我建议避免使用后者,因为前者更为常见,并且对阅读您的代码的人不会造成混淆。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.