Author Topic: Shortcuts for including C++ library files and namespaces?  (Read 2814 times)

Offline igottamarlin

  • Single posting newcomer
  • *
  • Posts: 2
Shortcuts for including C++ library files and namespaces?
« on: July 10, 2017, 03:59:16 pm »
I'm a noob to C++ and programming in general, but I just made a header file with these two lines:

#include <iostream>
using namespace std;

Is that a bad habit and will I ever have to stop doing that? I could add stuff to it, but I feel like at some point it will become detrimental to the user of the program. Does anyone else do that?

Offline stahta01

  • Lives here!
  • ****
  • Posts: 7582
    • My Best Post
Re: Shortcuts for including C++ library files and namespaces?
« Reply #1 on: July 10, 2017, 05:43:45 pm »
I'm a noob to C++ and programming in general, but I just made a header file with these two lines:

#include <iostream>
using namespace std;

Is that a bad habit and will I ever have to stop doing that? I could add stuff to it, but I feel like at some point it will become detrimental to the user of the program. Does anyone else do that?

Read the rules http://forums.codeblocks.org/index.php/topic,9996.0.html

Then post your off topic question on a website like https://cboard.cprogramming.com/forum.php

Tim S.
« Last Edit: July 10, 2017, 06:02:17 pm by stahta01 »
C Programmer working to learn more about C++ and Git.
On Windows 7 64 bit and Windows 10 64 bit.
--
When in doubt, read the CB WiKi FAQ. http://wiki.codeblocks.org

Offline sodev

  • Regular
  • ***
  • Posts: 497
Re: Shortcuts for including C++ library files and namespaces?
« Reply #2 on: July 10, 2017, 07:52:10 pm »
using namespace std;
Everyone who is writing this in an implementation file should be shot instantly, everyone who is writing this in a header file should be shot twice :D. For the reasoning behind this please check your favorite programming style guide ;).