GCC:- 'cout' is an undeclared function when #include <iostream> is included?
I'm getting the GCC compiler to work and have just scribbled this code for a test:
#include <iostream> int main() { int a; a = 5; cout << a; return 0; } But low and behold I recieve the message: "In function 'int main()': 'cout' undeclared (fisrt use this fuction) (Each undeclared......" and so forth. Why is cout and cin not recognised when "#include <iostream> is present. Maybe I'm doing something wrong...probably am. Help appreciated. |
Code:
#include <iostream> |
or:
Code:
#include <iostream> |
Quote:
using std::cout; using std::cin; using std::endl; Defining these at the top give you access to just typing: cout << "Whatever"; etc. :) |
Or:
#include<iostream.h> :) |
although for the majority of c++ headers the only difference between the <name> and <name.h> versions is the use of the std namespace there are some significant differences between iostream and iostream.h, you should not use iostream.h
|
All times are GMT -5. The time now is 08:32 AM. |