I have been frustrated by the lack of a time unit in all the C/C++ std librarys (hope I've got the right wording!). What is a function that I could use. I don't care if I write it or if it is in a library.

Thanx in advance!

#include <ctime>
#include <iostream>
#include <string>
#include <sstream>

class timestruct   {  
        int time_int;
        std::string time_str;
        timestruct()   {
           std::time_t rawtime;
           struct std::tm* ptm=std::localtime(&rawtime);
           std::ostringstream buff;
           buff << ptm->tm_hour << ":" << ptm->tm_min << ":" << ptm->tm_sec;      
        timestruct& operator= (const timestruct& t);
        friend std::ostream& operator << (std::ostream& out,const timestruct& tm)  {           
           return out << tm;

        operator int() const  {
            return time_int;

        operator std::string()  {
            return time_str;

int main ()  {
        int n=timestruct();
        std::string s=timestruct();
This question has already been answered. Start a new discussion instead.