|
-
October 27th, 2010, 05:54 PM
#1
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;
}
-
October 27th, 2010, 08:47 PM
#2
Re: using namespace std; declaration syntax error
 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
-
October 28th, 2010, 12:48 AM
#3
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
-
October 28th, 2010, 01:02 AM
#4
Re: using namespace std; declaration syntax error
 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.
Is your question related to IO?
Read this C++ FAQ article at parashift by Marshall Cline. In particular points 1-6.
It will explain how to correctly deal with IO, how to validate input, and why you shouldn't count on "while(!in.eof())". And it always makes for excellent reading.
-
October 28th, 2010, 11:20 AM
#5
Re: using namespace std; declaration syntax error
When were namespaces introduced to C++ anyway?
-
October 28th, 2010, 11:27 AM
#6
Re: using namespace std; declaration syntax error
 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
-
November 5th, 2010, 06:57 PM
#7
Re: using namespace std; declaration syntax error
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|