您好我正在使用boost Posix Time System.我上课了
class event{
private:
boost::posix_time::ptime time;
//some other stuufff
public:
string gettime(void);
}
//functions
string event::gettime(void){
return to_iso_extended_string(time.time_of_day());
}
Run Code Online (Sandbox Code Playgroud)
但是to_iso_extended_string不接受类型
boost::posix_time::time_duration
Run Code Online (Sandbox Code Playgroud)
只有类型
boost::posix_time
Run Code Online (Sandbox Code Playgroud)
这可以在这里看到
我想返回一个字符串以供以后输出等
我怎么解决这个问题?我无法在boost中看到转换方法
boost::posix_time::time_duration
Run Code Online (Sandbox Code Playgroud)
串起来.我是C++的新手,如果这是一个非常简单的话,我会道歉.
#include <boost/date_time/posix_time/posix_time.hpp>
#include <iostream>
int
main()
{
using namespace boost::posix_time;
const ptime start = microsec_clock::local_time();
const ptime stop = microsec_clock::local_time();
const time_duration elapsed = stop - start;
std::cout << elapsed << std::endl;
}
mac:stackoverflow samm$ g++ posix_time.cc -I /opt/local/include
mac:stackoverflow samm$ ./a.out
00:00:00.000485
mac:stackoverflow samm$
Run Code Online (Sandbox Code Playgroud)
请注意,您需要使用posix_time.hpp标头而不是posix_time_types.hpp包含I/O运算符.
| 归档时间: |
|
| 查看次数: |
9447 次 |
| 最近记录: |