错误:expected class-name before ‘{’ token
转自 http://yongshengfree.blog.163.com/blog/static/3525246520081023255997/
刚开始以为头文件语法写错了 经常碰到,记录一下
不过在查阅网上资料的时候也意外的收获了一些答案, 在此把它贴出来, 以示警醒:
You can get the error
expected class-name before ‘{’ token
if you try to define a class as a subclass, and the superclass isn't defined in the local scope.
WRONG
class Foo: public Bar // Foo is a subclass of Bar { // stuff };
RIGHT
#include "Bar.h" // this makes Bar recognized class Foo: public Bar { // stuff };