title: Using Beep sound on keystroke C++
body: <p>So I want to help a friend with a project and he needed something to make a sound on each keystroke. He reads data as integer values using std::cin and I wonder if it's in any way possible to make a function which will not modify the rest of his project using multi threading or overloading somehow the istream >> operator so it would make a beep sound on each key press.
  I tried this and I understand that the overloading concept is probably bad and that I probably don't understand how multi threading works but could you recommand some articles so I can learn to solve this kind of problem?Maybe event handling in c++ but I didn't find anything general, just event handling in game frameworks. Maybe some tips?
  Here's my excuse of code:</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;thread&gt;
  #include &lt;string&gt;
  #include &lt;conio.h&gt;
  #include &lt;windows.h&gt;
  using namespace std;
  
  
  //compile error very bad
  istream&amp; operator&gt;&gt;(istream&amp; in, int&amp; n)
  {
      int i=0;
      char c;
      string nr;
      nr.resize(30);
      do{
          c = getch();
          if(c &gt;= '0' &amp;&amp; c&lt;= '9' &amp;&amp; i &lt; 30)
          {
              cout&lt;&lt;c;
              Beep(1000, 10);
              nr[i++] = c;
          }
          if(c == '\b')
          {
              i--;
              cout&lt;&lt;"\b \b";
          }
      }while(int(c) != 13);
  
      //maybe like this and return void?
      n = stoi(nr);
  
      //or like this? even tho makes no sense to me that it would work?
      return  in&gt;&gt;stoi(nr);
  }
  
  void playBeep()
  {
      while(getch())
      {
          Beep(1000, 10);
      }
  }
  
  
  int main()
  {
      //maybe this?
      thred t(playBeep);
      t.join();
  
      //or this with the operator overload somehow?
      int arr[10];
      for(int i=0; i&lt;10;i++)
          cin&gt;&gt;arr[i];
  
      return 0;
  }
  </code></pre>