If you have chance to use C++11 and above, the best way to calculate the delta time is using std::chrono library. std::chrono library provides you a flexible collection of types that track time with varying degrees of precision.

std::chrono::steady_clock class is the best tool for measuring intervals. It represents a monotonic clock which will always be moving forward and will never decrease. std::chrono::steady_clock is not useful to tell real world time. It is only useful to measure the passage of time.It can be almost anything as long as it continues to move forward, such as the duration since the beginning of the program execution, since the computer has been turned on, an so on.

You can calculate the delta time as below: