Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: downloads/boost_1_34_1/libs/array/array4.cpp @ 33

Last change on this file since 33 was 29, checked in by landauf, 16 years ago

updated boost from 1_33_1 to 1_34_1

File size: 1.3 KB
Line 
1/* example for using class array<>
2 * (C) Copyright Nicolai M. Josuttis 2001.
3 * Distributed under the Boost Software License, Version 1.0. (See
4 * accompanying file LICENSE_1_0.txt or copy at
5 * http://www.boost.org/LICENSE_1_0.txt)
6 */
7
8#include <algorithm>
9#include <functional>
10#include <string>
11#include <iostream>
12#include <boost/array.hpp>
13
14int main()
15{
16    // array of arrays of seasons
17    boost::array<boost::array<std::string,4>,2> seasons_i18n = {
18        { { { "spring", "summer", "autumn", "winter", } },
19          { { "Fruehling", "Sommer", "Herbst", "Winter" } }
20        }
21    };
22
23    // for any array of seasons print seasons
24    for (unsigned i=0; i<seasons_i18n.size(); ++i) {
25        boost::array<std::string,4> seasons = seasons_i18n[i];
26        for (unsigned j=0; j<seasons.size(); ++j) {
27            std::cout << seasons[j] << " ";
28        }
29        std::cout << std::endl;
30    }
31
32    // print first element of first array
33    std::cout << "first element of first array: "
34              << seasons_i18n[0][0] << std::endl;
35
36    // print last element of last array
37    std::cout << "last element of last array: "
38              << seasons_i18n[seasons_i18n.size()-1][seasons_i18n[0].size()-1]
39              << std::endl;
40
41    return 0;  // makes Visual-C++ compiler happy
42}
43
Note: See TracBrowser for help on using the repository browser.