-1

EDIT: After a comment of Remy Lebeau, I was able to fix a part of my program. But now, I get this error:"error: could not convert 'siteName' from 'std::vector >' to 'std::__cxx11::string' {aka 'std::__cxx11::basic_string'}"

It's me ... again... I'm still working on that Account Manager and I encountered another problem. Whenever I try using the saveFunction()

saveFunction(ofstream& save, string site, string url, string username, string password)
{
    save << site << endl;
    save << url << endl;
    save << username << endl;
    save << password << endl;

}

that I've created to save the variables values in my text file, I get this odd error (title).

Which totally blocks me right now, because without it, once the program return main() is called everything that was wrote in the program just disappears and so the program is useless.

Here's my full code: https://pastebin.com/dFxjqXyE

#include <iostream> ...

Thanks to everyone who'll take of his time to help me.

-Ange-Emmanuel

Solar
  • 29
  • 5
  • 1
    Don't edit your question to a new question. Instead ask a new question, but make sure to provide a [mcve] in the question itself. If you reduce your problem to a *Minimal* failing example, you may even be able to figure out the mistake yourself. – chtz Mar 04 '19 at 10:15

1 Answers1

0

Pass the ofstream object by reference. It's a non-copyable resource.

saveFunction(ofstream& save, string site, string url, string username, string password)

It doesn't make sense to "copy" I/O streams. Think of your physical printer, you can share the printer, but you cannot "copy" the printer

WhiZTiM
  • 21,207
  • 4
  • 43
  • 68
  • Hi thanks for your answer, this indeed solved the problem stated here. However it created another one, now I get "error: could not convert 'siteName' from 'std::vector >' to 'std::__cxx11::string'" but only on the siteName argument. Looking forward to your answer. – Solar Mar 03 '19 at 21:24
  • 1
    @Solar you are trying to pass `vector` variables where single `string`s are expected. You need to extract the desired `string` from each `vector` and pass them individually,or change the parameters to take the entire `vector`s. – Remy Lebeau Mar 03 '19 at 23:15