C++ Have a function repeat in the background

前端 未结 2 775
[愿得一人]
[愿得一人] 2021-01-27 18:21

I am using microsoft visual express.

I have viewed the accepted answer for this question and it seems to not be doing what I want it to do.

This is the function

2条回答
  •  日久生厌
    2021-01-27 19:08

    Use std::thread with this function:

    #include 
    
    void foo() {
        // your code
    }
    
    int main() {
        std::thread thread(foo);
        thread.join();
    
        return 0;
    }
    

提交回复
热议问题