我想在db中的一个表中插入信息(view 1 insert_info())
在下面的代码中,我希望为变量nom_journal提供我在第二个方法(METHODE 2 (same_path) )中返回的值same_path [nom_journal=same_path]。
我尝试给变量nom_journal函数的名称,因为它返回了一个字符串,但是它不能工作。它给出了以下错误
no matching function for call to 'Journal::find_nom_journal()'*甲基1:*
void Journal::insert_info()
{
Db_response::ConnectionFunction();
//Variables
int id_journal= getId_journal();
string nom_journal = find_nom_journal(); // --> THIS IS THE ERROR
string s_id_journal(to_string(id_journal));
string insert_query = "INSERT INTO `info_journal`(`id_journal`, `nom_journal`, `date`, `id_fournisseur`, `id_atm`, `state`, `state_parse_journal`, `terminal`, `id_utilisateur`) VALUES ('"+s_id_journal+"','"+nom_journal+"',' ' ,' ' ,' ' ,' ' ,' ' ,' ' ,' ' )";
//int qstate = mysql_real_query(conn,insert_query.c_str(), strlen(insert_query.c_str()));
query_state=mysql_query(conn, insert_query.c_str());
if(!query_state)
{
cout << "Query Execution Problem " << mysql_errno(conn) << endl;
}
else
{
cout << endl << "success" << endl;
}
}METHODE 2**
string Journal::find_nom_journal(const char* path)
{
string filename = string(path);
ifstream file1(filename);
string str_path = string(path);
//find filename
unsigned found = str_path.find_last_of("/\\");
string same_path = str_path.substr(found+1);
//cout << "this is the file name" << endl;
cout <<same_path << endl;
return same_path;
}发布于 2022-05-26 08:16:06
问题是方法find_nom_journal有一个类型为const char*的参数,但是在调用它时,没有传递任何参数:
//------------------------------------v---->you're aren't passing any argument here, but you should because it has a prameter of type const char*
string nom_journal = find_nom_journal( );要解决问题,您应该在调用find_nom_journal时传递一个适当类型(const char*)的参数。
https://stackoverflow.com/questions/72388753
复制相似问题