【VC编译错误】error C2872: 'ofstream' : ambiguous symbol

描述:

今天VC6.0编译时,出现了:

error C2872: 'ofstream' : ambiguous symbol

的错误。

错误原因:

定义重复,编译器不知道想要的是哪个定义了

原语句:

ofstream file;

解决方法:

1、修改原语句为

::ofstream file;
//或
std::ofstream file;

2、修改头文件

#include <iostream>   
#include <fstream>

using namespace std;

  

PS:

  

原文地址:https://www.cnblogs.com/75zzz/p/2837471.html