这应该算是一个C语言遗留问题。
问题出现条件:
#include <fstream.h>后有语句using namespace std;
比如
#include <fstream.h>
#include <string>
using namespace std;
分析:
fstream 和 fstream.h是两个不同的文件。前者是C++标准化以后的,后者是C++标准化之前的。如果包含了fstream.h之后再用using namespace std,编译器就不知道用哪一个文件了。
解决办法:
1,把#include <fstream.h>换成#include <fstream>
2,把using namespace std;换成using std::string;
ERROR: 'fstream' : ambiguous symbol
最新推荐文章于 2025-01-03 16:18:51 发布
本文详细解析了C++中使用fstream和fstream.h时出现的符号冲突问题,并提供了两种有效的解决方法:一是将fstream.h替换为fstream,二是修改usingnamespace std为usingstd::string。
1532

被折叠的 条评论
为什么被折叠?



