12-10-2004, 12:18 PM
What does it do?
Thanks!!
Thanks!!
"using namespace std; " in c/c++
|
12-10-2004, 12:18 PM
What does it do?
Thanks!!
12-10-2004, 12:41 PM
Namespaces are used to collect together functions and objects from a library. They just make things nicer by adding a prefix... so if you had:
Code: namespace MyNamespace You can either declare a new instance of the class by doing this: Code: MyNamespace::SomeClass someInstance; Or you can save time and code clearer by using the 'using' statement: Code: using namespace MyNamespace; // somewhere at the top This also applies for the stdlib; for example, the official name of the 'string' class is: Code: std::string However, by adding 'using namespace std;' to the top of your program, you only have to type: Code: string (P.S. could somebody tell me how to tell phpBB that I specifically want C++ code in the code tags?)
img]http://www.cdsoft.co.uk/misc/shiftlynx.png[/img]
12-10-2004, 01:00 PM
Oh, thanks!!!
12-10-2004, 06:39 PM
Quote:(P.S. could somebody tell me how to tell phpBB that I specifically want C++ code in the code tags?) [syntax = <<c>>][/syntax jsut replace '<<' and '>>' with quotations Oz~
12-10-2004, 10:39 PM
On short -they help to clear things up and avoid nameclashes.
url]http://fbide.sourceforge.net/[/url]
12-14-2004, 09:16 PM
You can do things like
Code: using std::cout; One thing you mustn't do is using "using" in a header. |
« Next Oldest | Next Newest »
|