Membership

posted in World of Sshado
Published September 20, 2006
Advertisement
Wow, time flies, I had no idea that my membership expired today. I haven't posted all year until this month. Interesting...

I will ask this in a forum, but since some people actually read my journal maybe you can answer a quick simple question:

Should I get used to using => std:: or am I fine using => using namespace std; at the top of my code?

I have been using the second choice, but I see a lot of people using std::
Previous Entry Visual Studio installed
Next Entry Ugh
0 likes 5 comments

Comments

Mushu
Depends on the situation -

In a header, or other distributed file: Don't pollute the global namespace with a using declaration. People probably won't like that.

In a source or implementation file: It'll all get compiled away nicely, and won't affect other parts of the project. using namespace is fine.

Or, at least, that's what I do lol -

#include "PAIN_Config.h"
#include "PAIN_FMOD.h"
#include "PAIN_GUI.h"
#include "PAIN_Log.h"
#include "PAIN_OGL.h"
#include "PAIN_SDL.h"
#include "PAIN_VFS.h"

using namespace pain::config;
using namespace pain::core;
using namespace pain::fmod;
using namespace pain::gui;
using namespace pain::log;
using namespace pain::ogl;
using namespace pain::sdl;
using namespace pain::vfs;
September 20, 2006 03:19 PM
superpig
Bear in mind that you don't need to drag the /whole/ std namespace in - you can single out particular symbols, e.g. "using std::string".
September 20, 2006 03:42 PM
Iced_Eagle
Quote:Original post by superpig
Bear in mind that you don't need to drag the /whole/ std namespace in - you can single out particular symbols, e.g. "using std::string".


This is the approach I take. Use "using" only for objects you will need... No need to include _everything_.
September 20, 2006 04:10 PM
Sshado
Thanks all, it makes sense now. I think I will try to get used to only using the ones I need :)
September 20, 2006 05:35 PM
Sshado
Thanks all, it makes sense now. I think I will try to get used to only using the ones I need :)
September 20, 2006 05:35 PM
You must log in to join the conversation.
Don't have a GameDev.net account? Sign up!
Profile
Author
Advertisement

Latest Entries

Rogue Fighter

3149 views

Prototypes

1489 views

New plan

1109 views

Triple Monitor KVM?

1455 views

Ugh...

1146 views

WTF

1050 views

Score!

935 views

Stuff ordered

969 views
Advertisement