Click here to Skip to main content
15,905,508 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi
Recently when I was writing c++ programs in VS 2010 I started getting the error
"
error c2039 is not a member of global namespace
" on separating the interface and implementation.

why would this happen?

What I have tried:

it was resolved as sooon as i changed the order of my # include directives. My header files went down and standard header files went up. the issue was resolved. I was lucky to have read this somewhere or may be, being meditative helped me.
Posted
Updated 22-Mar-17 1:41am

in the include section the standard header files should always precede the class files written by programmer.
 
Share this answer
 
The common solution is to include those system and library header files on top of your header files that are required to compile the header file without errors.

That means that a source file containing only an include statement for your header file (probably after including stdafx.h; see below) should compile without errors.

Visual Studio is a little bit special here because many of the Windows system header files are usually included with stdafx.h when using pre-compiled headers. But including the same files again does not harm (they are skipped by guarding or using #pragma once).

Including all necessary header files in your header file ensures that it can be also used for other projects and when pre-compiled headers are disabled. While this might be not not necessary for a single project, it is good style and allows re-using for other projects.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900