Stroustrup’s Programming Principles and Practice 3rd edition graphics: why passing a callback function to Window::timer_wait gets unexpected results?
Section 14.6 (Simple animation) in Stroustrup’s “Programming Principles and Practice using C++” third edition uses his PPP graphics library, which in turn makes use of QT. I am trying to understand what is involved.
The following program works as intended: initially it displays two black circles. After 2 seconds the first circle changes color to red. After four more seconds the second circle changes color to blue.
Stroustrup writes: “You can also add an action (“callback”) as an argument. That action is invoked after the delay”. So I experimented by replacing the indicated lines of code with code that does this. I expected the output to be exactly the same, but it is not. At two seconds nothing happens, but at four seconds both circles change color at the same time.
Stroustrups PPP third edition graphics: why does passing a callback function as an argument to Window::timer_wait have unexpeted results?
Section 14.6 (Simple animation) in Stroustrup’s “Programming Principles and Practice using C++” third edition uses his PPP graphics library, which in turn makes use of QT. I am trying to understand what is involved.
The following program works as intended: initially it displays two black circles. After 2 seconds the first circle changes color to red. After four more seconds the second circle changes color to blue.
Stroustrup writes: “You can also add an action (“callback”) as an argument. That action is invoked after the delay”. So I experimented by replacing the indicated lines of code with code that does this. I expected the output to be exactly the same, but it is not. At two seconds nothing happens, but at four seconds both circles change color at the same time.