C++
C++ 语言在2010年6月编程语言排行榜中排名第三位。下面就是 GregorianTest.cpp 程序:
01: #include <iostream>
02: #include "boost/date_time/gregorian/gregorian.hpp"
03:
04: using namespace std;
05: using namespace boost::gregorian;
06:
07: void writeline(date dt);
08:
09: int main()
10: {
11: date dt(1582, 10, 4);
12: writeline(dt);
13: date_duration dd(1);
14: writeline(dt + dd);
15: }
16:
17: void writeline(date dt)
18: {
19: cout << dt.day_of_week() << " " << dt << endl;
20: }
02: #include "boost/date_time/gregorian/gregorian.hpp"
03:
04: using namespace std;
05: using namespace boost::gregorian;
06:
07: void writeline(date dt);
08:
09: int main()
10: {
11: date dt(1582, 10, 4);
12: writeline(dt);
13: date_duration dd(1);
14: writeline(dt + dd);
15: }
16:
17: void writeline(date dt)
18: {
19: cout << dt.day_of_week() << " " << dt << endl;
20: }
安装 C++ 编译器、boost 库,编译和运行:
ben@ben-1520:~/work$ sudo apt-get install g++ libboost-dev
ben@ben-1520:~/work$ g++ --version
g++ (Ubuntu 4.4.3-4ubuntu5) 4.4.3
Copyright (C) 2009 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
ben@ben-1520:~/work$ g++ –o GregorianTest GregorianTest.cpp
ben@ben-1520:~/work$ ./GregorianTest
Mon 1582-Oct-04
Tue 1582-Oct-05
ben@ben-1520:~/work$
运行结果和 .NET 平台的编程语言一样。
