Expected initializer before ‘Foo’
From Cppsyntax
You can get the error
expected initializer before ‘Foo’
if you use Java syntax instead of C++ syntax for making a subclass.
WRONG
#include "Foo.h"
class Bar extends Foo
{
// stuff
};
RIGHT
#include "Foo.h"
class Bar: public Foo
{
// stuff
};
It also happens when you forget to put a semicolon at the end of a class definition:
WRONG
#include "Foo.h"
class Bar
{
public:
int aMethod();
} // without semicolon
int Bar::aMethod() { return 0; } // compiler signalizes error at this line
RIGHT
#include "Foo.h"
class Bar
{
public:
int aMethod();
};
int Bar::aMethod() { return 0; }
