今天写程序的时候, 遇到这样一个错误expected class-name before ‘{’ token 最后发现原来是我的头文件声明没有加. 继承时不要忘记加基类的头文件 错误: class Foo: public Bar // Foo is a subclass of Bar { // stuff }; 正确: #include "Bar.h" // this makes Bar recognized class Foo: public Bar { // stuff }; 转载…
Linux C/C++编程时常会遇到“error: expected expression before ‘struct’”错误,此错误一般是由未定义的宏(宏里套宏)或参量引起,导致编译器判断当前语句为非法语句,可能有如下几种情况. 1.缺少ioctl.h头文件 调用ioctl函数,用到参数VIDIOC_QUERYCAP时无法编译通过. 解决办法: #include <sys/ioctl.h> 2.#define错误 比如: #define X =5 int z=X+1; 解决办法: 修正#d…