Undefined sysmbol 'cout', unable to open iostream.h

I download dev-c++ and write simple programe.
but after compiling that prog i'm facinf problems with errors with iostrea.h and undefined sysmbol cout, cin.

so what could be the possible causes of the error???
You are not using using namespace std; or you are not using:
1
2
std::cout
std::cin
Last edited on
#include<iostream>
class Name
{
public:
char name[26];
void Print()
{
cout<<"Enter Your Name :"/n;
cin>>name;
}
void display()
{
cout<<"Your Name Is :"name;
}
};
int main()
{
Name N1;
N1.Print;
N1.display;
return 0;
}

that's how i wrot the programme after compiling error : Unable to open iostream, and undefined sysmbot cout and cin.

So..?
He said the answer. You either do:

1) Pop a using namespace std; under #include <iostream>

OR

2) Put a std:: before your cout and cin, so they look like std::cout or std::cin.
Last edited on
it gives error after compiling:
error..\..\..\..\tc\include\iostream.h 3: incorrect pragma directive option: push
You've got one error at least anyway. I recommend you use a string instead. Try this -

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#include <iostream>
#include <string>
using namespace std;
class Name
{
public:
string myString;
void nameProcess()
{
cout << "Enter your name." << endl;
getline (cin, myString);
cout << "Your name is: " << myString << "." << endl;
};

int main()
{
Name N1;
N1.nameProcess();
return(0);
}


The original code mehulpachchigar posted compiles for me after adding "using namespace std" and fixing common syntax problems like missing parentheses and semicolons.
Yeah. But since the 2 functions (Print() and display()) are very short, it won't hurt to make them into one function. And strings might be better for holding a name, unless you plan on operating on each separate character.
thanks, the problem get solved by adding std:: before cout and cin with dev-c++.
but i still have problem with the same project in borland Turbo C++ V. 3.0.
But All,

As i compile the programe and run it, i got the message according to programe, i can input the data, but how can i see my out put or result.

F9 for compile and exicute what for Result or what are the codes for to see result directly after input of date.

Thanks
Well because you used return(0), the program will terminate when it reaches there, without a pause (on most IDE's).
Good thing for you, is that there's a WHOLE thread on that topic. It's sticked so you can read it. It's full of plentiful responses, so take some time and read the replies.

Link - http://www.cplusplus.com/forum/beginner/1988/
Topic archived. No new replies allowed.