In C++ whats the best way tofor me to create an object and have it wait 1 minute before echoing a message? Please note it will be in a while loop(duh or else program will close/end).
In C++ whats the best way tofor me to create an object and have it wait 1 minute before echoing a message? Please note it will be in a while loop(duh or else program will close/end).
ctime (time.h) - C++ Reference
Have a look at that reference (time.h). In this case, look at clock() time() and difftime().
One option, which is portable but a Bad Idea in most cases, is to use the clock() and/or time() functions to busy wait until a minute has elapsed. The issue is that this approach uses 100% CPU usage (or as much as the OS is willing to hand over to your program anyway).
The other options depend on which OS you are using and are not portable. In Windows there is Sleep(). I'm not sure about *nix. This is far preferable to a busy wait (busy because it keeps checking the value of time() or checking how many clock()'s have elapsed, or however you decide to structure it). Not only does it not stress the CPU, but it makes your program play nicer with other programs.
C+/- programmer extraordinaire