Expected class-name before ‘LEFTCURLYBRACE’ token

From Cppsyntax

Jump to: navigation, search

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
 };
Personal tools