Hello, I was just looking up the threads and I must say I saw a lot of codes with "std::string", "std::cout", etc... I just wanna ask, wouldn't it be better if you just wrote "using namespace std" instead ? I am doing it all the time, but if it's wrong please tell me so I'd stop :)
robertmacedonia
0
Junior Poster in Training
Recommended Answers
Jump to Postusing namespace std;
is correct. That allows you to avoid typing std all the time in your code.
Jump to Postwhere did no change it? Looks the same to me.
include <iostream> namespace A { int var = 10; <<< error here }; namespace B { int var = 20; <<< error here }; using namespace A; <<< error here using namespace B; <<< error here <snip>
Ehh …
Jump to Postsemicolons
A semicolon by itself is considered a null statement, and has no meaning. Modern compilers will typically complain about them unless they explicitly terminate a statement. For exampleint number_of_lightbulbs_to_change; ;
That second semicolon, while probably not an error, is also not useful, so the compiler will complain. …
Jump to PostEhh ?? Those aren't errors.
Oops! you are right -- I didn't read it close enough.
All 15 Replies
vulpecula
0
Newbie Poster
Ancient Dragon
5,243
Achieved Level 70
Team Colleague
Featured Poster
William Hemsworth
1,339
Posting Virtuoso
patryksharks321
0
Newbie Poster
Ancient Dragon
5,243
Achieved Level 70
Team Colleague
Featured Poster
William Hemsworth
1,339
Posting Virtuoso
Ancient Dragon
5,243
Achieved Level 70
Team Colleague
Featured Poster
ArkM
1,090
Postaholic
William Hemsworth
1,339
Posting Virtuoso
Ancient Dragon
commented:
you are right :)
+34
gregorynoob
2
Junior Poster in Training
CoolGamer48
65
Posting Pro in Training
ArkM
1,090
Postaholic
Duoas
1,025
Postaholic
Featured Poster
VernonDozier
commented:
Good summary
+5
William Hemsworth
commented:
Thats a nice big post :)
+3
Prabakar
commented:
Yes, Really nice:)
+1
Ancient Dragon
5,243
Achieved Level 70
Team Colleague
Featured Poster
William Hemsworth
commented:
Hehe, you make me laugh :)
+3
William Hemsworth
1,339
Posting Virtuoso
iamthwee
commented:
For posting code with compiling /testing.
-3
Alex Edwards
commented:
It has happened to me before too - you're not alone! =)
+3
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.