error C2872: 'ifstream' : ambiguous symbol

I'm getting this error in my Visual C++ project when I compile:

c:\TYVCPROG\PROGRAMS\NIC2\nic.cpp(62) : error C2872: 'ifstream' : ambiguous symbol
Error executing cl.exe.

Here's the part of the files thats causing the problem:


Nic.cpp
----------------------
#include <afx.h>
#include "spellAPI.h"
#include <string.h>
#include <fstream.h>
#include "Node.h"
.....

//opens the text file for input as inDictFile
  ifstream inDictFile(PathName,ios::in)



Node.h
----------------------
#include<string>
#include<map>
#include<vector>
#include<iostream>

Any ideas wht I'm getting ifstream as ambiguous? Does it have anything to do with the includes for iostream.h and fstream.h?
Pls help!
nicolacAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

nietodCommented:
>> Does it have anything to do with the
>> includes for iostream.h and fstream.h?
Yes.  Those are older "new" include files.  Switch to the versions without the .h files <iostream> and <fstream> and the problem will go away.

continues
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
nietodCommented:
One difference will be that the include files you used try to place their contents in the global namespace and the proper include files (the ones I suggested) place them in the "std" namespace.  (The ones you were using, use the ones I suggest and that is what leads to this problem at times.)  So when you switch to the files I suggested, you will find that all the classes etc are now in the "std" namespace, so you will either have to proceed the names with "std::" like

std::fstream Fil;

or you will have to use a using declaration like

using namespace std;

to tell the compiler to use all the contents of the std namespace.
0
nicolacAuthor Commented:
Thanks a million. :)
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
C++

From novice to tech pro — start learning today.