visual studio.net 2003 professional : problem with header

S

sg10241024

Hello,

I included the header "iostream"

Why is there only the possiblity of including
#include<iostream>? From Visual C++ 6 I know the iostream.h.


The name doesnt't really interest me. But it should work. The library
consists of the commands like "cout", "cin", ... But if I want to use
these commands I get an compiler error that they are unknown.

What's the problem? Do I miss something?

Thanks
Sarah
 
A

Antti Keskinen

There's a subtle difference.

"iostream.h" is the header file for the old Standard C++ Library. This file
is deprecated in Visual C++ .NET 2003. Instead, you must use "iostream"
header and specify the namespace "std" to access the good-old "cout", "cin"
etc functions. If you wish to know more of this behaviour, search MSDN with
string "iostream differences from Standard C++ Library"

There are two choices you can use. Which one you choose is a matter of
preference and taste. Naturally, it may be a matter of namespace clashing if
you have similarly named functions, objects or structures as the Standard
C++ Library.

Solution #1: The 'using namespace' keyword (generally safe)

#include <iostream>
using namespace std;

cout << "This will print a line of text" << endl;

----

Solution #2: Full namespace resolution (always safe, but bulkier)

#include <iostream>

std::cout << "This will print a line of text, too" << std::endl;

----

Hope this helps

-Antti Keskinen


sg10241024 said:
Hello,

I included the header "iostream"

Why is there only the possiblity of including
#include<iostream>? From Visual C++ 6 I know the iostream.h.


The name doesnt't really interest me. But it should work. The library
consists of the commands like "cout", "cin", ... But if I want to use
these commands I get an compiler error that they are unknown.

What's the problem? Do I miss something?

Thanks
Sarah
 
I

Ioannis Vranos

sg10241024 said:
Hello,

I included the header "iostream"

Why is there only the possiblity of including
#include<iostream>? From Visual C++ 6 I know the iostream.h.


The official ISO C++ standard (ISO/IEC 14882:1998, and 2003) defines
<iostream>.


VC++ 6 was a pre-standard compiler. A nice book to get you up and
running with ISO C++, is "Accelerated C++" by Andrew Koenig, Barbara Moo:

http://www.acceleratedcpp.com



If you want to learn the entire language (which will take *years*), is
"The C++ Programming Language" 3rd Edition or Special Edition by Bjarne
Stroustrup, the creator of C++:

http://www.research.att.com/~bs/3rd.html




The name doesnt't really interest me. But it should work. The library
consists of the commands like "cout", "cin", ... But if I want to use
these commands I get an compiler error that they are unknown.

What's the problem? Do I miss something?

Thanks
Sarah


using namespace std;
 

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

Top