using namespace std; declaration syntax error
I am using Turbo C++ version 3.0, see the following code,
when compiled, causes declaration syntax error
#include<iostream.h>
#include<conio.h>
#include<fstream.h>
using namespace std;
int main()
{
//using namespace std;
ofstream f;
clrscr();
f.open ("ittuz.txt");
cout<<"Created";
f<<"This is a file generated by c++ pgm \n ";
f<<"by /n /t Ajmal thagha Muhammed";
cout<<"Wrted to file";
f.close();
cout<<"closed";
getch();
return 0;
}
Re: using namespace std; declaration syntax error
Quote:
Originally Posted by
junaidsherief
I am using Turbo C++ version 3.0, see the following code,
The reason for your error is that you are using an old, outdated, obsolete compiler. It is totally useless if you want to learn C++ as it stands today in the year 2010.
C++ was standardized in 1998. That compiler goes back to 1992! You can't get anywhere using that dinosaur.
There are many free, modern ANSI C++ compilers available. Visual Studio Express, gcc/mingw, etc. Please get one of these compilers, and then start over.
As to your code, the correct headers are <iostream> and <fstream>, not <iostream.h> and <fstream.h>.
Regards,
Paul McKenzie
Re: using namespace std; declaration syntax error
#include<iostream.h>
#include<conio.h>
#include<fstream.h>
are technically correct but are old code from C, use it without the .h
Re: using namespace std; declaration syntax error
Quote:
Originally Posted by
tyranthacker
#include<iostream.h>
#include<conio.h>
#include<fstream.h>
are technically correct but are old code from C, use it without the .h
Except for conio, those are neither "technically correct", nor from C.
Re: using namespace std; declaration syntax error
When were namespaces introduced to C++ anyway?
Re: using namespace std; declaration syntax error
Quote:
Originally Posted by
Zaccheus
When were namespaces introduced to C++ anyway?
I believe they were in the original ARM (Annotated Reference Manual) before standardization in 1998, but no compiler was forced to implement them until 1998.
Regards,
Paul McKenzie
Re: using namespace std; declaration syntax error