News:

The new Release 25.03 is out! You can download binaries for Windows and many major Linux distros here .

Main Menu

Shortcuts for including C++ library files and namespaces?

Started by igottamarlin, July 10, 2017, 03:59:16 PM

Previous topic - Next topic

igottamarlin

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?

stahta01

Quote from: igottamarlin 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?

Read the rules http://forums.next.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.
C Programmer working to learn more about C++.
On Windows 10 64 bit and Windows 11 64 bit.
--
When in doubt, read the CB WiKi FAQ. [url="http://wiki.codeblocks.org"]http://wiki.codeblocks.org[/url]

sodev

Quote from: igottamarlin on July 10, 2017, 03:59:16 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 ;).