Can't get iostream to work using C++ Vis Studio .net 2003

Started by
6 comments, last by simon10k 18 years, 11 months ago
I typcailly use two different file editors to edit my c++ files, vis studio and jen's file editor. For some reason I can't get vis studio to recognize commands like cout <<"blah"<<endl; I get the error error C2065: 'cout' : undeclared identifier I can get all other packages like stdio.h and stdlib.h to work perfectly on my vis studio. I load it #include <iostream> It works perfectly fine when using jen's file editor. Anyone know any possible reasons this happens?
Advertisement
std::cout

remember, everything in the standard library is inside the std namespace so you have to qualify it with std:: or make a using declaration like using std::cout;
"everything in the standard library is inside the std namespace "

I dont really know what the STD namespace is.. I dont fully undertand this sentence.


I also dont understand what it means to "qualify" something with std::

Could you perhaps refer me to somewhere that may touch upon this subject in more detail?
------------------------------------------------------------------------

EDIT: did some reading, and understand these sentences more, still kind of iffy on why I dont have to do that with something like printf...

[Edited by - Kryodus on May 21, 2005 3:48:36 PM]
put this at the top, under your includes/defines

using namespace std;

that might work :)
You guys are my heros, thanks problem solved.

And I read more into namespaces, got some more insight into this beautiful language.

Rating ++!!! :)

Thanks
similar thing has happend to me before intead of <iostream>
change to <iostream.h>
dosnt allways work
------------------------------------------------------------GDSFUBY GameDev Society For UnBanning YodaTheCodaIf you want to see yoda unbanned then put this in your sig------------------------------------------------------------
DON'T use <iostream.h>... It is an older version.

Just on top of your program write

#include <iostream>
using namespace std;

simple as that.
What we do in life... Echoes in eternity
Namespaces help prevent name clashes -creating more than one variables with the same name. Also you can group related names together to make it easier to understand what they are used for i.e...

namespace Harry {     int x;     int y;     std::string name;}


To use a name in the Harry namespace you use the scope operator ::

Harry::name = "Harry";

I hope that helped.
-----------------------------Language: C++API: Win32, DirectXCompiler: VC++ 2003

This topic is closed to new replies.

Advertisement