Reputation: 2268
This is currently how I am getting system time:
void Sum_AnalogClock::GetSystemTime()
{
std::time_t t = std::time(0); // get time now
std::tm* now = std::localtime(&t);
angleSeconds = now->tm_sec;
angleMinutes = now->tm_min;
angleHours = now->tm_hour;
if (angleHours > 12)
angleHours -= 12;
}
Do I need to delete now;
?
Upvotes: 2
Views: 579
Reputation: 292
No, according to the STD - std::localtime returns a "pointer to a static internal std::tm object on success".
So no need to delete anything.
Lior
Upvotes: 4
Reputation: 1134
No, according to [1] it points to an internal data structure, so you don't need to delete it.
[1] https://en.cppreference.com/w/cpp/chrono/c/localtime
Upvotes: 6