错误代码:无匹配函数供呼叫
error code: no matching function for call to
我正在尝试读取文件并将其存储在数组中。
这是我用来打开文件的代码的一部分:
int readFile(AccessRecord & file, Files & namesIn)
{
std::ifstream fin(file.fileName);
if (fin.fail())
return -1;
}
这是我去编译时遇到的新错误:
[meg21allred@LinuxLab08 ~]$ g++ myAssign02.cpp
myAssign02.cpp: In function ‘int readFile(AccessRecord&, Files&)’:
myAssign02.cpp:72:35: error: no matching function for call to
‘std::basic_ifstream<char>::basic_ifstream(std::string&)’
std::ifstream fin(file.fileName);
如果我只使用std::cout << file.fileName;
,它似乎可以打印出正确的文件名,但是当我将file.fileName
放入ifstream line
看起来您正在使用一个尚未支持ifstream
构造函数的非常旧的编译器,该 CC_4构造函数在2011年添加到C 标准库中。取了const char*
(老式的C风格字符串(,因此请尝试:
std::ifstream fin(file.fileName.c_str());
相关文章:
- 无匹配函数呼叫getline()
- 通过呼叫constexpr函数来定义静态constexpr成员
- 来自QvariantList的std ::函数的通用呼叫
- 将整数(文字)与函数相关联,让呼叫者查询拖鞋的数量
- 错误:呼叫构造器的匹配函数无匹配功能
- 当在函数调用中递增值时,程序正常工作,但是如果我们在单独的行中增加值而不是呼叫函数,则会出现错误.为什么
- 在呼叫运算符函数const中调用运算符时错误
- 在函数呼叫时,请从异质初始化列表中构建元组
- 使用makeword函数创建错误e0109-表观呼叫的括号前表达式必须具有(指针到 - )函数类型
- C 函数呼叫没有足够的模板参数
- 为什么此函数通过类型函数指针调用后,呼叫明智地行为
- 如何根据呼叫线以不同的方式求解函数
- C 线程 - 无匹配函数供呼叫
- 匿名构造函数和击曲函数在矢量中呼叫
- 当Bool值在UPDATE()方法中更改时,只有一次呼叫函数
- GDB呼叫函数 - 如何使用std :: cout作为参数
- 呼叫函数直接与发射信号(QT-信号和插槽)
- boost ::适配器::转换为boost :: apapters ::过滤呼叫函数两次
- 编写函数的定义,该函数接受可呼叫函数作为参数
- C 错误:呼叫函数模板没有匹配功能