User forums > Using Code::Blocks
Single source, without a project file?
Michael:
--- Quote from: 280Z28 on January 14, 2006, 09:02:52 pm ---I also suggest learning how to program without the using directive. It is bad practice to use it, and stops the whole reason namespaces were added to the language in the first place. The core code::blocks code is written without ever using it. :)
--- End quote ---
Yes, right. This topic was discussed (or partially discussed) sometimes ago already :D.
Michael
yop:
--- Quote from: RKCole on January 14, 2006, 08:13:46 pm ---From what I've learned through working with compilers is to make sure that "using namespace std;" is included before your "main" function so you can use "cout", "cin", and others without adding "std::".
--- End quote ---
You can always do something like:
using std::cout;
using std::cin;
There is a lot of discussion about the usefullnes of "using" a whole namespace against "using" some symbols only.
EDIT: Wow that using namespace thingy triggered immediate responces, I didn't even have the time to press the post button and two replies allready :shock:
Ceniza:
And nobodoy has told him how to use it with single source files.
Projects are really important in programming and have many advantages, but for small test programs I think it's too much. When you start dividing your code in many source files (at least two), it's time to use projects and see why they are so useful, IMHO (and please, don't start a war here).
A drawback of single files compiling with Code::Blocks is the debugger won't work with them (it still needs a project, but it's just an implementation issue).
I'd suggest you getting one of the nightly builds 'cause there have been some improvements in the single file compiling since RC2.
Now, it's just a matter of creating a new file, writing your code, clicking on build and clicking on run (there's also a build & run button :))
RKCole:
So it is better to use std::coud, std::cin, and so forth?
I didn't have much of an advantage while in my C++ Programming I and C++ Programming II (advanced) courses at my college due to the fact that our professor wrote his own books for the courses, and he did not know a lot about C++. (Makes no sense to me on that one...) So to some point, I am going to have to re-learn a lot of things.
Thanks for the input about that, though, because I was always curious about that particular topic, and everyone always adised me to place that "using namespace std;" line in my code. Sorry if I caused any problems or anything. :)
Take care.
killerbot:
using namesace std;
that's the easy way, say one thing and get all, and this makes evrything visible again, which is not that good. namespaces divide, hide, and prevent collisions.
it is indeed better to put using std::cout; for example if you only want cout.
Meyers and Sutter advice it like that also.
Navigation
[0] Message Index
[#] Next page
[*] Previous page
Go to full version