Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > std::cout << "sdfsdf" in MS Visual Studio 2005

Reply
Thread Tools

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

 
 
ek
Guest
Posts: n/a
 
      12-23-2006
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?

 
Reply With Quote
 
 
 
 
Pete Becker
Guest
Posts: n/a
 
      12-23-2006
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)
 
Reply With Quote
 
 
 
 
fireflyc
Guest
Posts: n/a
 
      12-23-2006

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()
{
.......
}

 
Reply With Quote
 
ek
Guest
Posts: n/a
 
      12-23-2006

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.

 
Reply With Quote
 
David Harmon
Guest
Posts: n/a
 
      12-23-2006
On 23 Dec 2006 06:21:34 -0800 in comp.lang.c++, "ek" <>
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>

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Enabling browser back button for GridView Paging and Sorting in Ajax1.1 and 3.5 (using Visual Studio 2005/ Visual studio 2008) anil reddy ASP .Net 0 02-11-2009 04:22 PM
Is Visual Studio 2005 complict with Visual Studio 2003 rockdale ASP .Net 1 08-23-2006 07:20 PM
Should I write Visual studio 2005 or Visual studio 2003 MCSD =?Utf-8?B?VmlqYXk=?= Microsoft Certification 14 06-30-2006 09:05 AM
Should I write Visual studio 2005 or Visual studio 2003 MCSD =?Utf-8?B?VmlqYXk=?= Microsoft Certification 0 06-29-2006 07:05 PM
visual studio .net 2003 verses visual studio .net 2002 wh ASP .Net 2 01-16-2004 04:54 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57