c++ - How does std::cin works? -
i int doing following:
int num; cin >> num;
i string doing following:
string word; cin >> word;
my question is: how cin
conversion internally? ever output error if enter unexpected? example: "ɔool ʇǝxʇ ƃǝuǝɹɐʇoɹ oulıuǝ". safeguard cin uses?
i'm new c++
note >>
operator. c++ provides ability define functions give functionality built-in operator. (note, cannot create new operators don't exist in language.) in particular case, >>
operator has been overloaded use cin
, either int
or string
. these functions carry out conversion. in case of int
version, set error flag in cin
if input cannot converted int
.
Comments
Post a Comment