Skip to main content
gamedev.net
🔒 Locked

header file problems

Started by Bytez Aug 1, 2006 at 7:34 AM 3 replies 550+ views
Original Post
Bytez
Bytez
hi, i have a .h file that includes for use with the class it goes with... now all is ok except my main program automatically is able to use std:: etc without me including it myself, so the header is passing it on. how can i stop this as its a bit messy and i would preffer to keep my .h includes within themselfs.
PolyVox
PolyVox
That doesn't make sense... doesn't import the namespace just puts some stuff in it. Are you sure you don't have 'using namespace' anywhere is you header?

Can you post all you code given that it's only 2 files?
CTar
CTar
If your header needs std::basic_string objects (not pointers) then you can't avoid it.
ju2wheels
ju2wheels
Avoid adding using namespace std; in your custom header files. Just include the proper standard headers you need for your class declaration and manually specifiy the namespace for the types (like std::string).

Do that in your class headers and in the cpp you can safely use using namespace std; and not have to worry about headers exposing the entire namespace wherever your header is included.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.