Simulate Timer In C++11

The following content involves the concepts of synchronous and asynchronous. Here is a C++ class that simulates a timer. Output asynchronously. To simulate a timer for sequentially outputting numbers, we can do it like this: We cannot execute the task of rendering frames by creating a new thread in this Read more…

std::thread and std::mutex

std::thread #include <iostream> #include <thread> #include <chrono> void f1(int n) { for (int i = 0; i < 5; ++i) { std::cout << “function f1 executing\n”; ++n; std::this_thread::sleep_for(std::chrono::milliseconds(10)); } } void f2(int& n) { for (int i = 0; i < 5; ++i) { std::cout << “function f2 executing\n”; ++n; Read more…

File IO Between QFile And std fstream

The article show demoes about use ifstream to read file written by qfile and use qfile to read file written by ofstream. Use ifstream to read file written by QFile #include <QCoreApplication> #include <QString> #include <QFile> #include <iostream> #include <fstream> int main(int argc, char *argv[]) { QCoreApplication a(argc, argv); QString Read more…

Books
: All books written by website manager

X