C++ - how does Sleep() and cin work?

后端 未结 7 1868
独厮守ぢ
独厮守ぢ 2021-02-05 10:38

Just curious. How does actually the function Sleep() work (declared in windows.h)? Maybe not just that implementation, but anyone. With that I mean - how is it implemented? How

7条回答
  •  孤街浪徒
    2021-02-05 11:07

    'cin' uses a ton of overloaded operators. The '>>', which is usually right bit-shift, is overloaded for pretty much every type of right-hand operand in C++. A separate function is provided for each one, which reads from the console and converts the input into whichever variable type you have given. For example:

    std::cin::operator>> (int &rhs);
    

    That's not real C++ — I haven't worked with streams and overloading in a while, so I don't remember the return type or the exact order of arguments. Nevertheless, this function is called when you run cin >> an integer variable.

    The exact underlying implementation depends on the operating system.

提交回复
热议问题