error: no matching function for call to 'std::basic_ifstream<char>::open(std::string&)
来源:互联网 发布:javascript动画 编辑:程序博客网 时间:2024/05/22 15:09
原文地址: http://blog.csdn.net/cs_zlg/article/details/8300124
- string filename = "1.txt";
- ifstream fin;
- fin.open(filename);
上述语句会产生如下错误:
error: no matching function for call to 'std::basic_ifstream<char>::open(std::string&)
原因是C++的string类无法作为open的参数。
解决方案:使用C的字符串。
例:
- char filename[10];
- strcpy(filename, "1.txt");
- ifstream fin;
- fin.open(filename);
0 0
- error: no matching function for call to 'std::basic_ifstream<char>::open(std::string&)
- error: no matching function for call to 'std::basic_ifstream<char>::open(std::string&)
- error: no matching function for call to 'std::basic_ifstream<char>::open(std::string&)
- error: no matching function for call to 'std::exception:exception(const char[16])'
- 【求助】 no matching function for call to `strcpy(std::string&, char*&)'
- G++编译错误 no matching function for call to '_tag_data_value::StringAddLen(std::string, int, int)
- error: no matching function for call to
- error: no matching function for call to 'MainWindow::connect(*&, ...)
- no matching function for call to ‘transform
- no matching function for call to ‘transform
- no matching function for call to 'sort(...),
- std::string to char*
- no matching function for call to 'strstr(stdstring&, const char [4])'
- C++ STL string 大小写转换时的 no matching function for call to ‘transform 错误
- C++ STL string 大小写转换时的 no matching function for call to ‘transform 错误
- C++中错误no matching function for call to transform
- [c++]no matching function for call to ‘sort(…)......
- 【C++错误处理】no matching function for call to transform
- 批处理之 正确使用for语句 以及!errorlevel!、%errorlevel% 与 DelayedExpansion用法详解
- 数据结构学习 队列 二叉树
- 2014-2015 ACM-ICPC Northeastern European Regional Contest (NEERC 14)
- 静态碎片切换 和动态viewpage切换和view颜色切换
- TensorFlow实战之:Quick Start
- error: no matching function for call to 'std::basic_ifstream<char>::open(std::string&)
- bzoj4569[Scoi2016]萌萌哒
- LayoutInflater的错误用法(Avoid passing null as the view root )
- Linux下的进程通信方式: 管道通信详解
- 简单的 URL 编程
- okhttp方法上传图片和接收图片
- hdu1503 Advanced Fruits
- 最大的数
- vector的用法小结