473,569 Members | 2,438 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

fstream error on SUN

The following snippet code throws an error while compiling on SUN os..

Any idea how to resolve this...

#include <iostream.h>
#include <fstream.h>
#include <math.h>
#include <algorithm>
using namespace std;

..........
..........

fstream fp;
fp.open((*it).c _str(),ios::in) ; // Line 223
.......
.......
fp.open((*it).c _str(),ios::in) ; // Line 345
The error is as follows:

line 223: Error: The name fstream is ambiguous, fstream and
std::fstream.
line 345: Error: The name ios is ambiguous, ios and std::ios.

TIA, ratzeel

Nov 8 '05 #1
3 2610
ratzeel wrote:
The following snippet code throws an error while compiling on SUN os..

Any idea how to resolve this...

#include <iostream.h>
Not a standard C++ header
#include <fstream.h>
Not a standard C++ header
#include <math.h>
#include <algorithm>
These two are OK
using namespace std;

.........
.........

fstream fp;
fp.open((*it).c _str(),ios::in) ; // Line 223
......
......
fp.open((*it).c _str(),ios::in) ; // Line 345
The error is as follows:

line 223: Error: The name fstream is ambiguous, fstream and
std::fstream.
line 345: Error: The name ios is ambiguous, ios and std::ios.

TIA, ratzeel


http://www.parashift.com/c++-faq-lit....html#faq-27.4

Gavin Deane

Nov 8 '05 #2
Thanks. The problem gone away by removing the using namespace std line.

Nov 9 '05 #3

ratzeel wrote:
Thanks. The problem gone away by removing the using namespace std line.


A summary of your problem is:

#include <iostream.h>
#include <fstream.h>

using namespace std;

<some code using the names fstream and ios>

line 223: Error: The name fstream is ambiguous, fstream and
std::fstream.
line 345: Error: The name ios is ambiguous, ios and std::ios.

Do you understand why removing
using namespace std;
makes the problem go away?
http://www.parashift.com/c++-faq-lit....html#faq-27.5

You could equally well make the problem go away by including the
standard <iostream> and <fstream> headers instead of <iostream.h> and
<fstream.h>, as the FAQ I first pointed to suggests.
http://www.parashift.com/c++-faq-lit....html#faq-27.4

Your headers ending in .h are non-standard, which means that the next
compiler you use may or may not provide tham at all, and even if it
does, the contents may or may not be the same as what you are used to
using.

On the other hand, if you learn how to use the standard headers, you
will get identical functionality available on every conforming C++
compiler.

If you understand all that and you are happy with the non-standard .h
headers then that's fine. But bear in mind that this group discusses
standard C++ so you won't be able to get help here with code that
relies on your particular implementation of <iostream.h>

Gavin Deane

Nov 9 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
4910
by: Newsgroup - Ann | last post by:
The fstream is supposed to be a replacement of the stdio.h and the exception is supposed to be a replacement of the return error code. So how do I replace my old codes of the style: if (output = fopen(...) == NULL) { perror("..."); exit(1); } by the C++ style? The only thing I can do now is like
6
3192
by: Armando | last post by:
Hallo ! I habe some error in my programm,because i use <fstream.h>,I want to use <fstream> but i don´t know which fonctions i must modify in my program ? Thanks you for your help. Armando.
6
3205
by: David Briggs | last post by:
I am using MS VC++ 6.0 with MFC I have a simple class: #include <fstream.h> class Data { public: CString WriteStr(); Data();
1
4948
by: Pasacco | last post by:
Dear When I was installing a software written in C++, following error message appeared, in my platform (gcc version 3.2.2 20030222 Red Hat Linux 3.2.2-5). I guess that this problem might be comming from a configuration or g++ version compatibility. If someone has this experience, let us know how to shoot this trouble. Thankyou ...
3
7105
by: Catweasel | last post by:
I'm new to C++ and have been chucked in at the deep-end. I have a C++ console app that works fine. All I want to do is write to file however as soon as I include the fstream library and try to compile VS .net chucks out errors, lots of them: c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\include\cstdio(17) : error C2143: syntax...
9
5275
by: Someonekicked | last post by:
In my program, I need to open multiple files, and I wont know till after the program execution how many of them (user will enter that value). So I am using a vector of fstream. I am using fstream since I will need to write and read from files, and I am using those files as binary files. I made a sample of what's going on (below). Without...
1
5343
by: MForey | last post by:
I'm attempting to create a program that uses fstream objects to read/write to files. However, it is currently balky at best. The fstream.write call doesn't return an error, but the modified data doesn't show in the next read, or when I open the file itself. Additionally, I get a insufficient parameters error from if I remove the ios flags from...
6
17116
by: wiso | last post by:
My problem is this (from: http://www.cplusplus.com/ref/iostream/fstream/open.html) #include <fstream> using namespace std; int main() { fstream f;
6
3723
by: Gaijinco | last post by:
Should this do something? #include <fstream> #include <string> int main() { std::fstream filestr ("test.txt", std::fstream::in | std::fstream::out); std::string s="";
0
7703
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7618
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
1
7679
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7983
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
5223
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3657
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3647
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1228
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
946
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.