Expected initializer before ‘x’

From Cppsyntax

Jump to: navigation, search

You can get the error

 expected initializer before ‘x’

if you forget an equals sign:

WRONG

 void foo()
 {
   int x = 2;
   int y x;           // should be an equals sign
 }


RIGHT

 void foo()
 {
   int x = 2;
   int y = x;           // ahhh, better!
 }
Personal tools