Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / Managed C++ / May 2004

Tip: Looking for answers? Try searching our database.

Newbie help needed on "IOStream.h" vs "IOstream", namespaces etc.

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
as mellow as a horse - 30 May 2004 18:20 GMT
I'm not new to C++, but it has been a while, and I'm defintely new to dot
net.

So to get back into the swing of things, I tried to create the ubiqitous
"hello world" program using a console application.  Most of the C++
programming I've ever done has been in Borland products (mostly C++ Builder)
and all I ever needed to do a "hello world" was include "iostream.h".

But when I do that in dot net, I get a fatal error saying file not found.
After much searching through online help, I find I have to drop the "h" and
just include "iostream".  But when I did that I found my cout line was
causing an error.  After much more searching through help files, I discover
I have to qualify cout with a namespace i.e. "std::cout" or use a "using
namespace std" directive.  I've never used namespaces in C++ before,
although I'm aware of them through dabbling in XML.

So all works well, but then I find that namespaces only apply to "iostream"
and I can use "iostream.h" to avoid having to use them.  So my question is
(at last!):

How do I include "iostream.h" when dot net can't/won't find it, and should I
be doing so anyway i.e. is it the done thing now to use namespaces
everywhere and thus only use iostream?
William DePalo [MVP VC++] - 30 May 2004 20:44 GMT
> I'm not new to C++, but it has been a while, and I'm defintely new to dot
> net.

Roger.

> So to get back into the swing of things, I tried to create the ubiqitous
> "hello world" program using a console application.  Most of the C++
> programming I've ever done has been in Borland products (mostly C++ Builder)
> and all I ever needed to do a "hello world" was include "iostream.h".

The problem here is not with .Net per se but with the changes in ISO
standard C++. VS' compiler, per the standard, no longer supports
<iostream.h>. You'll need to use <iostream> (no extension) instead.

> How do I include "iostream.h" when dot net can't/won't find it,
> and should I be doing so anyway

Nope.

> i.e. is it the done thing now to use namespaces
> everywhere and thus only use iostream?

Many people use

using namespace std;

in source (not in header!!!!)

others will fully qualify names, e.g,

   std::cout

You probably want to check a good text like ones from Herb Sutter for the
gory details, stylistic and otherwise.

Regards,
Will
Carl Daniel [VC++ MVP] - 30 May 2004 22:44 GMT
> How do I include "iostream.h" when dot net can't/won't find it, and
> should I be doing so anyway i.e. is it the done thing now to use
> namespaces everywhere and thus only use iostream?

To expand on Will's statements a bit -

<iostream.h> is the main header file for "classic" or "pre-standard"
IOStreams, as originally produced by AT&T.  <iostream> is the main header
file for "standard" IOStreams, as standardized in the C++ standard (ISO
14882:1998) some six years ago.

VC6 supported <iostream.h> well and <iostream> poorly (VC6 was finalized
before the C++ standard was finished).  VC7 supported both systems, but
began to flag the older pre-standard streams as "deprecated".  VC7.1, aka
VS.NET 2003 dropped support for pre-standard streams altogether.

In many cases, all you need to do is drop the .h and add a using
declaration, or qualify references to the names.  But there are other
differences - for example, pre-standard streams let you specify the sharing
mode when opening a file with an fstream.  Standard iostreams have no
concept of file sharing modes, so if you need that kind of control, you have
to use vendor-specific extensions for support.

There were other (more drastic) changes made to the basic hierarchy of
streams classes, including most significantly, the fact that (nearly) all of
the streams classes are now templates, parameterized on the type of
character you're using (char or wchar_t).

If you're interested in the gorey details, the book "Standard  IOStreams and
Locales" by Angelika Langer and Klaus Kreft is the authoritative work on the
subject.

-cd

Rate this thread:







Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.