.
#include <fstream>
instead, because it's the standard C++ (different from C header file). This should fix the problem.
The std namespace is used in the C++ headers, not for the C ones. Hence the problem you saw.
and look at 17.3.1.1
Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.
If you mix extension-less header files with *.h header files, and use "using namespace std" the compiler will see two sets of the same declarations, and will not know which one to use. (ambiguity)
For this to happen it doesn't require you to mix both <fstream> and <fstream.h>. You could be mixing <fstream.h> and <iostream>, and you will still get the "ambiguity" error.
The compiler tries to understand what "ifstream" means in your code.
whether It is std::ifstream or ::ifstream ?
It is easy for compiler if your code and the header files in your code have
only std::ifstream or have only ::ifstream.
However,the compiler can not decide what "ifstream" represents for when your code
and your header files have both std::ifstream and ::ifstream. In this case, "ifstrea"
is an ambiguous symbol"
For solving this problem, you need to help the compiler understanding what you mean
when you use "ifstream". As previous comments, don't use fstream.h is
the easy way for fixing this bug is. However, if you still want to use fstream.h, you need
to put #include files and "using namespace std" in correct order and
you need to specify to use std::ifstream or ::ifstream
The following is an example :
#include <fstream.h>
#include <fstream>
using namespace std;
void foo()
{
::ifstream old_stream;
std::ifstream new_stream;
// "ifstream:ambiguous symbol" if using the next line
// ifstream ambiguous_stream;
}
The above code doesn't error when compiling.
Note : the following code will has error at compiler time because
using namespace in incorrect order
#include <fstream>
using namespace std;
#include <fstream.h>
.....
If you think your question was not answered at all, you can post a request in Community support (please include this link) to refund your points.
The link to the Community Support area is:
PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!
======
Werner
ComTech
CS Admin @ EE