std::cout << "sdfsdf" in MS Visual Studio 2005

E

ek

I thought that the syntax for c++ in either winXP or linux was the
same.

In Ubuntu linux it works fine if I write:

#include <string>
using namespace std;

int main()
{
string bb = "fff";
std::cout << bb;
return 0;

}

But in winXP in MS Visual Studio 2005 'cout' is not recognized in 'std'

I also have to declare a string like: std::string s = "ffff". Why does
'using namespace std' not work in winXP.

What are there reason for this and are there many cases where C++
syntax in linux is not compatible with C++ syntax for MS Visual Studio?
 
P

Pete Becker

ek said:
I thought that the syntax for c++ in either winXP or linux was the
same.

In Ubuntu linux it works fine if I write:

#include <string>
using namespace std;

int main()
{
string bb = "fff";
std::cout << bb;
return 0;

}

But in winXP in MS Visual Studio 2005 'cout' is not recognized in 'std'

I also have to declare a string like: std::string s = "ffff". Why does
'using namespace std' not work in winXP.

What are there reason for this and are there many cases where C++
syntax in linux is not compatible with C++ syntax for MS Visual Studio?

#include <iostream>

--

-- Pete
Roundhouse Consulting, Ltd. (www.versatilecoding.com)
Author of "The Standard C++ Library Extensions: a Tutorial and
Reference." (www.petebecker.com/tr1book)
 
E

ek

fireflyc skrev:

The problem was that I typed 'using namespace std;' in a header file.
It seems that this is a wrong use and it should be typed in each source
file.
 
D

David Harmon

On 23 Dec 2006 06:21:34 -0800 in comp.lang.c++ said:
The problem was that I typed 'using namespace std;' in a header file.
It seems that this is a wrong use and it should be typed in each source
file.

No, that is not the problem; there is no header file in your example in
which you could have typed the using directive. The problem as others
have noted is the missing #include <iostream>
 

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

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top