没有匹配函数来调用... [英] No matching function for call to...

查看:114
本文介绍了没有匹配函数来调用...的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的代码的这个特定部分出现了这个特定的错误。还有其他两个地方,但我想如果我能解决一个问题,我可以解决其他问题。此错误适用于此部分代码,ins.open(fileName.c_str());



I am getting this specific error for this specific part of my code. Two other places as well, but I think if I can solve one I can solve the others. This error is for this part of the code, "ins.open(fileName.c_str()) ;"

void openInfile (ifstream& ins)
{
	string fileName = " " ;
	ofstream outs ;		// outs is an output stream
	cout << "Enter file of madlibs outline." << endl ;
	cin >> fileName ;
	ins.open(fileName.c_str()) ;		//connects ins to file inFile
	if (ins.fail (fileName.c_str()))
	{
		cerr << "Error: Unable to open file : FILENAME" << endl ;
	}
	else
	{
		openOutfile (outs) ;
	}
}





我的尝试:



我已经要求很多人帮助我并通过许多类似的问题进行研究,但我仍然找不到任何帮助我的方法。



What I have tried:

I have asked many people to help me and have researched through many similar questions, but I still can't find anything to help me.

推荐答案

引用:

if(ins.fail(fileName.c_str()))

if (ins.fail (fileName.c_str()))

To

To

if ( ins.fail() )


你的问题在
if (ins.fail (fileName.c_str()))

你只需要

You just need

if (ins.fail)

你可能想要改变

cerr << "Error: Unable to open file : FILENAME" << endl ;

类似

cerr << "Error: Unable to open file : " << filename.c_str() << endl ;


这篇关于没有匹配函数来调用...的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆