我正在使用boost::gregorian
來執行日期計算。我想用add_month
具體根據例子(電流的1.63 http://www.boost.org/doc/libs/1_63_0/doc/html/date_time/examples.html)add_month從boost :: gregorian中刪除?
/* Simple program that uses the gregorian calendar to progress by exactly
* one month, irregardless of how many days are in that month.
*
* This method can be used as an alternative to iterators
*/
#include "boost/date_time/gregorian/gregorian.hpp"
#include <iostream>
int main()
{
using namespace boost::gregorian;
date d = day_clock::local_day();
add_month mf(1);
date d2 = d + mf.get_offset(d);
std::cout << "Today is: " << to_simple_string(d) << ".\n"
<< "One month from today will be: " << to_simple_string(d2)
<< std::endl;
return 0;
}
然而,這提供錯誤消息
month.cpp: In function `int main()':
month.cpp:33:5: error: `add_month' was not declared in this scope
add_month mf(1);
^
month.cpp:35:19: error: `mf' was not declared in this scope
date d2 = d + mf.get_offset(d);
^
錯誤報告:https://svn.boost.org/trac/boost/ticket/ 10627 – NathanOliver
您可以在''/ your-installation-path/libs/date_time/example/gregorian /' –