why i can't use iostream why >

Recommended Answers

All 4 Replies

Are you trying to use iostream or iostream.h?

Show us the code that doesn't work.

Which to use will depend on your compiler. Old Turbo C++ will use iostream.h but all recent compilers use <iostream> (without the .h extension)

You also need a using statement.

#include <iostream>
using std::cout;
using std::cin;

simple, in order to avoid using

using std::cout and using std::cin
you can do the following:

  1. #include<iostream>
  2. using namespace std;
  3. cout<<""; cin>>a;

the second line sends a message to the compiler you will also use a name space called standard wich is a place where cin and cout are located.

that way you don't have to call the namespace (std::) everytime you need to use cout or cin

using namespace std; is actually bad practice because it floods the program with everything in std namespace, and sometimes that causes name clashes with your own code. I cam across that very situation in another thread here at DaniWeb just today. Even Bjarne Stroustrup, the author of c++ language, adises against using namespace std; statement.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.