using namespace std
when I put this at the top of my code in MVC++ 6.0 I get an error saying there is no such namespace. I know of (which I use). Are these two similar and which is the most current?
Not sure what you are comparing std to, but are you using header files with .h at the end or without? Most of the time you will use header files without .h as that is the new standard.
-------------------------GBGames' Blog: An Indie Game Developer's Somewhat Interesting ThoughtsStaff Reviewer for Game Tunnel
stdlib.h is an old C header file. Namespaces are a C++ concept which do not exist in C, so the contents of C headers are in the global namespace. Newer C++ specific header files have their contents within "namespace std", and the compiler needs to be told which namespace to use. So, the rule is this: if you include a C++ header, which you can identify because it has no ".h" at the end of its name, then you must specify namespace std; if you use a C header, you do not need to specify any namespace. Lastly, if you have not #include''d a C++ header which declares namespace std, then any attempt to reference namespace std will fail. That''s the problem you''re getting.
Ya, I know all that but for instance if I type:
#include <iostream>
using namespace std;
int main(){
cout >> "Hello";
return 1;
}
I recieve an error from my compiler saying that there is no such namespace.
#include <iostream>
using namespace std;
int main(){
cout >> "Hello";
return 1;
}
I recieve an error from my compiler saying that there is no such namespace.
September 05, 2002 07:05 PM
Ok i put yours in and it returned an error, then i put my own in and it compiled fine :/.
This is mine :
#include <iostream>
using namespace std;
main()
{
cout << "Hi" << endl;
return 0;
}
This is mine :
#include <iostream>
using namespace std;
main()
{
cout << "Hi" << endl;
return 0;
}
quote: Original post by Zorbfish
cout >> "Hello";
dunno about the namespace problem but you seem to be a bit confused, you mean to write cout << "hello";
edit: spelling
[edited by - necromancer_df on September 5, 2002 8:15:12 PM]
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement