Jump to content
  • Advertisement
Sign in to follow this  
  • entries
    114
  • comments
    126
  • views
    64842

Membership

Sign in to follow this  
Sshado

157 views

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::
Sign in to follow this  


5 Comments


Recommended Comments

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;

Share this comment


Link to comment
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".

Share this comment


Link to comment
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_.

Share this comment


Link to comment
Thanks all, it makes sense now. I think I will try to get used to only using the ones I need :)

Share this comment


Link to comment
Thanks all, it makes sense now. I think I will try to get used to only using the ones I need :)

Share this comment


Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!