mardi 31 juillet 2018

How to use C++ Boost library by using constructor to Subtracts S seconds from self, returning self?

Here is the syntax of constructor of RW(Rogue-Wave) library, I need to write it using Boost library to meet same functionality, below is the RW syntax,

RWTime& RWTime::operator-=(unsigned long s);

output should be: It Subtracts s seconds from self, returning self

Here i tried to implement it using boost library, but not able to implement and if i include parameters then it gives error, i am new to the C++, Please anyone suggest me to do this further.

Here is my similar code(I think its wrong functionality i implemented), i found these methods from stack-overflow but not able to make it happen.

#include <iostream>
#include <boost/date_time/posix_time/posix_time.hpp>

using namespace boost::gregorian;
using namespace boost::local_time;
using namespace std;

class seconds
{
public:
seconds();
};
long seconds::seconds()
{
boost::posix_time::ptime utcTime { { 1901, 1, 1 } };
auto diff = boost::posix_time::second_clock::local_time() - utcTime;
cout<<diff.total_seconds();
cout<<"\n";
}

int main()
{
seconds obj;
}

This is my guess code, i am doing this because my requirement is to customize the boost to our own product use, I need below functionality in Boost code, please suggest me.

RWTime& RWTime::operator-=(unsigned long s);

output should be: It Subtracts s seconds from self, returning self

Aucun commentaire:

Enregistrer un commentaire