using namespace std;
The tutorials I get sent to often have this in them, but when i try to use this my compiler says, "Namespace name expected" ?
using namespace std;
The tutorials I get sent to often have this in them, but when i try to use this my compiler says, "Namespace name expected" ?
#include <iostream> // does not work
using namespace std; // does not work
try
#include <iostream.h> // this is the old style. So could solve ur problem
Have a wonderful day.... and keep smiling... you look terrific that way
signing off...
shiv... as i know him
http://cboard.cprogramming.com/showt...sing+namespace
edit: post some code, it should work. also what compiler?
Code:#include <iostream.h> using namespace std; int main() { cout << "Hello World\n"; }
Borland C++ 5.02
Either say
orCode:#include <iostream.h> int main() { cout << "Hello World" << endl; return 0; }
or even betterCode:#include <iostream> using namespace std; int main() { cout << "Hello World" << endl; return 0; }
Note: One of the members provided a link, please visit that. It will explain a lot of details about namespacesCode:#include <iostream> int main() { std::cout << "Hello World" << std::endl; return 0; }
Have a wonderful day.... and keep smiling... you look terrific that way
signing off...
shiv... as i know him
Try #include <iostream>
This does not work either:
I went to the link and I still don't see whats wrong
Code:#include <iostream> using namespace std; int main() { cout << "Hello World\n"; }
Nor does this work as std is not a class or namespace and there is a statement missing
Code:#include <iostream> int main() { std::cout << "Hello World" << std::endl; return 0; }
I have posted 3 forms of the program, you have tried only the 2nd and the 3rd. Try the first form. It must workOriginally posted by Noobie
Nor does this work as std is not a class or namespace and there is a statement missing
Code:#include <iostream> int main() { std::cout << "Hello World" << std::endl; return 0; }
Note: I don't use namespace at all in the first form
Have a wonderful day.... and keep smiling... you look terrific that way
signing off...
shiv... as i know him
but why? am i not supposed to ever use namespace? why is it in all the tutorials? Some of them call for
#include "string6.h" what is that? it doesnt work either
Chill outOriginally posted by Noobie
but why? am i not supposed to ever use namespace? why is it in all the tutorials? Some of them call for
#include "string6.h" what is that? it doesnt work either
The compiler that you are using might have been developed when namespaces were not existing as part of C++. So your compiler does not have most of the recently added features / libraries of C++. So just change to the latest compilers and your problem would be solved.
w.r.t namespaces
When you say #include<iostream.h>
everything is loaded into the global namespace at one shot
If you had split your contents into multiple sections (lets say std1, std2, std3, std4) and didn't want everything to be stuffed in the global namespace, then you could say
using namespace std1; and that would load only what is there in std1 in the global space and will not load std2 / 3/ 4 in the global namespace.
Having said that std1/2/3/4 was just to help you understand. There are no such namespaces available.. unless you create any with those names
Have a wonderful day.... and keep smiling... you look terrific that way
signing off...
shiv... as i know him
so i can only do tutorials written last year??
the above posted should work. that's weird. the "string6.h" is a different header file, most likely for a class.
for the "but why? am i not supposed to ever use namespace?", you could do this either of three ways...
using namespace std;
OR
using std::cout;
using std::endl;
//continue with more if necessary
OR
std::cout << std::endl;
//like in previous examples
using std::cout;
using std::endl;
//continue with more if necessary
OR
std::cout << std::endl;
uh... :< it seems pretty difficult to explain that Im a noobie asking for help on a HelloWorld compilation-i dont know what std is and I dont know what all that code u are telling me I could use is and I can't read some tutorial to find out when the tutorials dont even work