Discussion: Can anyone help me understand what my errors mean?
In the previous quiz, C++ online test, we tested our experience gained from the course.
3 messages from 3 displayed.
//= Settings::TRACKING_CODE_B ?> //= Settings::TRACKING_CODE ?>
In the previous quiz, C++ online test, we tested our experience gained from the course.
Hi, I know this output might seem a little bit messy, but actually it' not so difficult to understand. Let me show you, so you know, how to read it a next time.
prog5B.cpp
, then there is row
number or nothing. Where there is nothing, it's header, otherwise it's number of
row with error. So that concludes, you have 4 errors on lines 49, 50, 74 and
75.openInfile()
and second 2 in function
openOutfile()
.prog5B.cpp:49: error: no matching function for call to ‘std::basic_ifstream::open(std::string&)’
ifstream.open(string&)
, which you call on line
49. The second part of the error message even gives you hint, what to do. It's
not always right, but this time it's really helpfull.note: candidates are: void std::basic_ifstream<_CharT, _Traits>::open(const char*, std::ios_base::openmode) [with _CharT = char, _Traits = std::char_traits]
ifstream.open(char *)
, that
you had probably meaned to use. And really, when you look in the documentation -
http://www.cplusplus.com/…stream/open/ you're going to find
it there, even with the example.prog5B.cpp:50: error: no matching function for call to ‘std::basic_ifstream >::fail(std::string&)’
ifstream.fail(string&)
. Again look in the documentation - http://www.cplusplus.com/…s/ios/fail//3), 4) It's same as 1) and 2), but for the ofstream. Again the documentation can be found - http://www.cplusplus.com/…am/ofstream/
OK, now when error is clear, solution is in place. It's quite easy, you just have to pass right arguments into functions:
open()
functions don't accept string
,
but array of chars. You can convert string
to one by calling
c_str()
function on it.fail()
functions don't take any argument at all.I was in a good moode, so I even fixed the code for you and you can find it here. Hoping you bother yourself with reading this long tutorial of mine, on how to read these errors.
Anyway, even if this code now compiles just fine, I assume it won't do, what you want. But I think this is enough for this answer, so if you want futher help, please write here, what the code was supposed to do exactly. Thank you!
Sorry, I forgot to add the link for whole source code in the end, so here it is https://www.ict.social/dev-lighter/8
3 messages from 3 displayed.