In a class, I'm trying to get a member method to do all the work in it to produce a sleeping/waking time by making it about 20 seconds. Apparently, I'm getting an infinate loop. Any help is appreciated.
Code:#include <iostream> #include <ctime> // Other Methods Sleep( int seconds ) const { std::cout << "You begin to sleep..." << std::endl; clock_t EndSleeping; EndSleeping = clock () + seconds * CLK_TCK ; while (clock() < EndSleeping) {} int n; for (n=18; n>0; n--) { Sleep(1); } std::cout << "You wake up feeling refreshed." << std::endl; } int main() { using namespace std; Player.Sleep(1);