| | |
using namespace std problem
Please support our C++ advertiser: Intel Parallel Studio Home
![]() |
Hi guys,
i have one question, when i type
using namespace std;
at top of my program my compiler gives some error
especially syntax error!
my compiler is Borland C++ v.5
for example simple code:
Regards
i have one question, when i type
using namespace std;
at top of my program my compiler gives some error
especially syntax error!
my compiler is Borland C++ v.5
for example simple code:
c++ Syntax (Toggle Plain Text)
#include <stdio.h> #include <conio.h> #include <iostream.h> using namespace std; void main() { clrscr(); getch(); }
Regards
Farzad Zafarani
Shouldn't use void main. getch() isn't a great way of stopping the program. iostream.h is non-standard. use iostream:
C++ Syntax (Toggle Plain Text)
#include <iostream> using namespace std; int main( void ) { std::cin.ignore(); return 0; }
When using the old headers with .h extension you don't use "using namespace std". Check to see if your compiler supports the new headers without an extension and use those instead. The old files are out-of-date and will cause lots of other problems if you attempt to use current coding practices.
Don't PM me with questions -- you might get a nasty PM in response. If you have a question then post it in one of the forums.
•
•
•
•
Shouldn't use void main. getch() isn't a great way of stopping the program. iostream.h is non-standard. use iostream:
C++ Syntax (Toggle Plain Text)
#include <iostream> using namespace std; int main( void ) { std::cin.ignore(); return 0; }
std::cin.ignore()
why you use that?!
my compiler gives error on that line?!, is it for pausing the screen?!
Regards
Farzad Zafarani
•
•
•
•
When using the old headers with .h extension you don't use "using namespace std". Check to see if your compiler supports the new headers without an extension and use those instead. The old files are out-of-date and will cause lots of other problems if you attempt to use current coding practices.
•
•
•
•
The use of namespace std for all identifiers of the C++ standard library was introduced during
the standardization process. This change is not backward compatible to old header files, in which identifiers of the C++ standard library are declared in the global scope.
In addition, some interfaces of classes changed during the standardization process (however, the goal was to stay backward compatible if possible). So, a new style for the names of standard header files was introduced. This allows vendors to stay backward compatible by providing the old header files.
Two roads diverged in a wood, and I— I took the one less traveled by, and that has made all the difference.
by Robert Frost the "The Road Not Taken"
by Robert Frost the "The Road Not Taken"
![]() |
Similar Threads
- read to end of line problem (C)
- reversing number problem. (C)
- List <char *> Problem (C)
- help with first and second problem (C++)
- Brain Dead Night (C++)
- loop problem (C++)
- problem reading text file to struct (C++)
- C++ problem (C++)
- *Pointer program problem. (C++)
- need help problem with cin.getline method (C++)
Other Threads in the C++ Forum
- Previous Thread: C++ support for Graphics.h
- Next Thread: write and delete details on csv file in C++
| Thread Tools | Search this Thread |
Tag cloud for C++
api application array arrays based beginner binary bmp c++ c/c++ calculator char char* class classes code compile compiler console conversion convert count data delete deploy dll download dynamic dynamiccharacterarray encryption error file format forms fstream function functions game givemetehcodez graph gui homeworkhelp iamthwee ifstream input int java lib library linker list loop looping loops map math matrix memory microsoft newbie news number numbertoword output pointer problem program programming project python random read recursion recursive reference rpg simple sorting string strings struct temperature template templates test text text-file tree url variable vector video visual visualstudio void win32 windows winsock wordfrequency wxwidgets






