21 41 C:\Users\dell\Documents\xuexiukecheng.cpp [Error] no matching function for call to 'std::basic_ofstream<char>::basic_ofstream(std::basic_string<char>)'
时间: 2023-09-22 14:07:27 浏览: 202
这个错误提示是说,在你的 C++ 代码中,有一行代码调用了 std::basic_ofstream 的构造函数,但是参数类型和该构造函数所需的参数类型不匹配。更具体地说,构造函数需要一个类型为 std::basic_string 的参数,但是传入了一个类型为 char* 的参数。
解决这个问题的方法是将参数类型改为 std::basic_string,例如:
```cpp
std::string filename = "C:\\Users\\dell\\Documents\\xuexiukecheng.txt";
std::ofstream file(filename);
```
这样就可以成功创建一个 ofstream 对象并打开指定的文件了。
阅读全文
相关推荐

















