Archived

This topic is now archived and is closed to further replies.

n0ob

VC++6.0, ambiguous symbol.. fstream.. meh

Recommended Posts

n0ob    176
I''m having this really stupid error all of a sudden. I''m working on this big project, with lots of cpps and headers. I have a couple cpps that use fstream just fine. So I''m makin a new cpp, and I try to create an ifstream object, but what do I get?? THis: error C2872: ''ifstream'' : ambiguous symbol. So I have been looking everywhere, can''t find anything wrong. This is the line: ifstream fin("pobjs.txt"); It is in a member function of a struct defined in the appropriate header file. So I was wondering, has anyone had this error before and knows what to do? I''m really hoping that it is something stupid that can be easily fixed.. and not some kind of horrible multiple-files-and-their-order etc.. Thanks!

Share this post


Link to post
Share on other sites
SiCrane    11839
Did you try to change it to use std::ifstream instead of plain ifstream? It sounds like something else called ifstream was declared in a visible namespace.

Share this post


Link to post
Share on other sites
n0ob    176
error C2079: 'fin' uses undefined class 'basic_ifstream >'

There's not something weird with including fstream.h multiple times is there? The weird thing is that I commented all but one instance of #include <fstream.h> out, the only place the compiler said I needed it was in an .h file where a struct's member function took an ifstream& as a parameter. Bah.. thanks.. any more ideas?

[edited by - n0ob on January 15, 2004 12:24:35 PM]

Share this post


Link to post
Share on other sites
n0ob    176
Well, I guess all the cpps are somehow linked to fstream.h through my unfortunate tangle of #includes.. so never mind what I said about that.. BUT, it works in some cpps and not others..

Share this post


Link to post
Share on other sites
n0ob    176
Holy fek, I just did , but now ifstream is undeclared.. What is the replacement (So I don''t have to go read the file or msdn or whatever )

Share this post


Link to post
Share on other sites
fizban75    130
When you #include <fstream>, ifstream is in the "std" namespace. Either explicitly declare std::ifstream or put a using namespace std; in your cpp files where you use ifstream.

Share this post


Link to post
Share on other sites
n0ob    176
quote:
Original post by n0ob
error C2079: 'fin' uses undefined class 'basic_ifstream >'



I already tried that, remember? No workie :S Thanks

[edited by - n0ob on January 15, 2004 5:34:35 PM]

Share this post


Link to post
Share on other sites
n0ob    176
Okay,, wow.. I put the using namespace std; in the .h that the cpps were all including, and changed it to , and it worked! Thanks!!! Before I had using namespace std; in the afflicted cpp file.. Thanks a bunch!!

Share this post


Link to post
Share on other sites