我将一个大型VC++ 6.0应用程序转换为VS2010,并在其中一个项目中不断遇到此错误:
error C2248: 'std::basic_ios<_Elem,_Traits>::basic_ios' : cannot access private member declared in class 'std::basic_ios<_Elem,_Traits>'
1> with
1> [
1> _Elem=char,
1> _Traits=std::char_traits<char>
1> ]
1> c:\program files (x86)\microsoft visual studio 10.0\vc\include\ios(176) : see declaration of 'std::basic_ios<_Elem,_Traits>::basic_ios'
1> with
1> [
1> _Elem=char,
1> _Traits=std::char_traits<char>
1> ]
1> This diagnostic occurred in the compiler generated function 'std::basic_ofstream<_Elem,_Traits>::basic_ofstream(const std::basic_ofstream<_Elem,_Traits> &)'
1> with
1> [
1> _Elem=char,
1> _Traits=std::char_traits<char>
1> ]
根据错误文本和此处提出的类似问题,我认为错误是由
ofstream
实例直接传递给函数而不是通过引用传递引起的。我的问题是,找到以错误方式传递
ofstream
的代码行。该错误消息仅链接到VS2010中包含的fstream header ,并且我的项目在几万行代码的代码库中无处使用ofstream
(我自己都不写)。我将大力推荐任何帮助/技巧/策略来定位这种类型的编译器错误。您将如何处理定位此类错误的问题?
最佳答案
在源文件中执行grep
(正则表达式搜索),查找类似
\(([^,]+,)*, (std::)?of?stream [^&]
关于c++ - : error C2248: 'std::basic_ios<_Elem,_Traits>::basic_ios' : cannot access private member declared in class的Bug搜寻提示,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/8987459/