Adding time in format hh:mm in C++
<p>How can I do it in C++? </p>

<p>Example:</p>

<pre><code>time1 = 04:45; 
time2 = 02:25; 
result = time1 + time2;
result = 07:10
</code></pre>

<p>In which date type (string, double, etc) should time values be saved?</p>

<p>edit:
Is it possible from this code get <code>int h = 23</code> and <code>int m = 14</code>? In other words, how to print %H and %M?</p>

<pre><code>int main()
{
    std::tm t = {};
    std::istringstream ss("23:12");
    ss &gt;&gt; std::get_time(&amp;t, "%H:%M");
    if (ss.fail()) {
        std::cout &lt;&lt; "Parse failed\n";
    } else {
        std::cout &lt;&lt; std::put_time(&amp;t, "%R") &lt;&lt; '\n';
    }
}
</code></pre>