-1

Error:

no instance of overloaded function "std::basic_ofstream<_CharT, _Traits>::open [with _CharT=char, _Traits=std::char_traits]" matches the argument list

I get for this code:

void AddFriend(const char name) {

      std::ofstream Friend;
      Friend.open("data\\users\\",name,".user");
      Friend << name;
      Friend.close();
}
Shrug
  • 1
  • 2
  • 3
    This is not how you concatenate strings. Also, `name` is only 1 `char`, are you sure this is what you want? – Yksisarvinen May 14 '22 at 15:41
  • I solved that `error`, but now I get another one when compiling: `src\/include/Friend.hpp: In function 'void AddFriend(std::string)': src\/include/Friend.hpp:10: error: no matching function for call to 'std::basic_ofstream >::open(std::basic_string, std::allocator >)' e:\work\mingw\bin\../lib/gcc/mingw32/4.4.0/include/c++/fstream:696: note: candidates are: void std::basic_ofstream<_chart _traits="">::open(const char*, std::_Ios_Openmode) [with _CharT = char, _Traits = std::char_traits]` – Shrug May 14 '22 at 15:58
  • Looks like you have an ancient compiler that doesn't support C++11. If you can't update, probably the easiest would be to have `std::string path = std::string("data\\users\\") + name + ".user"; Friend.open(path.c_str());` – Yksisarvinen May 14 '22 at 16:24

0 Answers0