namespace

M

Michael

Hi,

In my compiler, I do not have to use
using namespace std;

the following codes works. Why?

#include <iostream>

int main()
{
cout<<"C++";
return 0;
}
 
T

Thomas J. Gritzan

Michael said:
Hi,

In my compiler, I do not have to use
using namespace std;

the following codes works. Why?

#include <iostream>

int main()
{
cout<<"C++";
return 0;
}

Because its broken.
 
I

Ian Collins

Michael said:
Hi,

In my compiler, I do not have to use
using namespace std;

the following codes works. Why?

#include <iostream>

int main()
{
cout<<"C++";
return 0;
}
Are you using an old version of gcc by any chance?
 
I

Ian Collins

Michael said:
Why to quote the text? And what do you mean gcc? Thanks!
It's what we do on Usenet. But we don't quote signatures (removed above).

As you obviously aren't using gcc, whatever compiler you are using is
broken.
 
T

Thomas J. Gritzan

Rolf said:
The code works because it's broken? Interesting theory.

That is a common theory in this newsgroup. When someone asks, why his
code works, a common answer is:
"The code is broken and invokes undefined behaviour, so everything can
happen, and it just seems to work properly"

But in this case I meant: The compiler is wrong.
 
R

Rolf Magnus

Thomas said:
That is a common theory in this newsgroup.
When someone asks, why his code works, a common answer is:
"The code is broken and invokes undefined behaviour, so everything can
happen, and it just seems to work properly"

That doesn't mean the code works _because_ it's broken. If it weren't
broken, it would still work.
But in this case I meant: The compiler is wrong.

Ok then.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,994
Messages
2,570,223
Members
46,812
Latest member
GracielaWa

Latest Threads

Top