By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
454,137 Members | 1,024 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 454,137 IT Pros & Developers. It's quick & easy.

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

P: n/a
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?

Dec 23 '06 #1
Share this Question
Share on Google+
4 Replies


P: n/a
ek wrote:
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)
Dec 23 '06 #2

P: n/a

Pete Becker wrote:
ek wrote:
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)
#include <iostream>
#include <string>
using namespace std;

int main()
{
.......
}

Dec 23 '06 #3

P: n/a
ek

fireflyc skrev:
Pete Becker wrote:
ek wrote:
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>

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.

Dec 23 '06 #4

P: n/a
On 23 Dec 2006 06:21:34 -0800 in comp.lang.c++, "ek" <ek*****@yahoo.com>
wrote,
>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>

Dec 23 '06 #5

This discussion thread is closed

Replies have been disabled for this discussion.