Expected identifier before ampersand token

From Cppsyntax

Jump to: navigation, search

You can get the error

 expected identifier before ‘&’ token

in many ways.

Typo in signature

One way is to put the & in the wrong place:

WRONG

 void foo(&int bar)  // ampersand goes before bar
 {
   // stuff 
 }


RIGHT

 void foo(int &bar)   // the ampersand is in the right place now
 {
   // stuff 
 }
Personal tools