Mystified by "error: expected unqualified-id before 'using'"?

So, I feel dumb for beating my head against a wall for half an hour on this, so I figured I'd share my ordeal with others to save them some time.

I had a class definition in a header file, and then implemented that class in a source file.

Header:
1
2
3
4
5
6
7
#include <blahblahblah>
using namespace std ;

class Foo
{
  /* class def */
}


Source:
1
2
3
4
5
#include <blahblahblah>
#include "Foo.h"
using namespace std ;

/* class implementation */


This resulted in several failed make attempts with the following message:

 
error: expected unqualified-id before 'using'


See my mistake yet?

I think this was probably born from my mostly-Java origins, but my error actually resides in the header, not the source.

I left the semicolon off the end of the class definition.

LFMF
You need semicolon after class definition. Also: do not use "using" in headers. It can change behavior of your program and break other headers authors of which did not expect spanish inquizition wild using declaration.
Topic archived. No new replies allowed.