Sleep is not declared in this scope, what is this?

Source: Internet
Author: User
Tags sleep function
1 #include <iostream>
2 #include <cstdio>
3 using namespace Std;
Ten class clock{
One public:
Clock (time_t t = 0)
13 {
tm*local = LocalTime (&t);
M_h = t? local-> tm_hour:0;
m_m = local-> tm_min;
m_s = local-> tm_sec;
Setbuf (Stdout,null);
19}
void run (void)
21 {
for (;;)
23 {
Show ();
Tick ();
26}
27}
Private:
void Show (void)
30 {
To printf ("\r%02d:%02d:%02d", m_h,m_m,m_s);
32}
tick void (void)
34 {
Sleep (1);
(++m_s = 60) {
Panax Notoginseng m_s = 0;
if (++m_m = = 60) {
m_m = 0;
if (++m_h = 24) {
M_h = 0;
42}
43}
44}
45}
M_h int;
m_m int;
m_s int;
49};
int main (void)
51 {
Clock Clock (Time (NULL));
//clock Clock
//clock.hello;
Clock.run ();
0;
57}
Clock1.cpp: in member function ' void Clock::tick () ':

Clock1.cpp:35:13: Error: ' Sleep ' has not been declared in this scope



Function Name: Sleep function: Perform suspend for a period of time usage: unsigned (unsigned milliseconds); Use with the top file in VC #include <windows.h> in the GCC compiler, The header file used differs from the GCC version #include <unistd.h>

The first English character in sleep in VC is the upper-case of "S" in standard C, which is sleep, not uppercase. Use uppercase to illustrate the following, Exactly what you use to see the compiler. Simple to say VC with sleep, the rest of the use of sleep. The general form of the sleep function: sleep (unsigned long), where the unit in sleep () is in milliseconds, so if you want the function to stay for 1 seconds, it should be sleep (1000); Under Linux, Sleep's "s" Do not capitalize the units in sleep () in seconds, not milliseconds. In the kernel, the realization of sleep is realized by both the pause function and the alarm function.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.