forked from boostorg/array
58 lines
3.2 KiB
HTML
58 lines
3.2 KiB
HTML
![]() |
<HTML>
|
||
|
<HEAD>
|
||
|
<TITLE>array4.cpp</TITLE>
|
||
|
</HEAD>
|
||
|
|
||
|
<BODY TEXT="#000000" BGCOLOR="#FFFFFF">
|
||
|
|
||
|
<TABLE HEIGHT=40 WIDTH="100%">
|
||
|
<TR> <TD ALIGN=LEFT WIDTH="100%" BGCOLOR="#DDDDDD">
|
||
|
<FONT face="Arial,Helvetica" size=+2><B>
|
||
|
array4.cpp
|
||
|
</B></FONT>
|
||
|
</TD></TR></TABLE><BR>
|
||
|
|
||
|
<BR><BR>
|
||
|
<TT>
|
||
|
<SPAN class="Source">
|
||
|
<Font color="0000FF" >/</FONT><I><FONT face="Arial,Helvetica,sans-serif" color="0000FF" >* example for using class array<></FONT></I><BR>
|
||
|
<I><FONT face="Arial,Helvetica,sans-serif" color="0000FF" >*/</FONT></I><BR>
|
||
|
#include <algorithm><BR>
|
||
|
#include <functional><BR>
|
||
|
#include <string><BR>
|
||
|
#include <iostream><BR>
|
||
|
#include <<A href="./array.hpp.html">boost/array.hpp</A>><BR>
|
||
|
<BR>
|
||
|
int main()<BR>
|
||
|
{<BR>
|
||
|
<I><FONT face="Arial,Helvetica,sans-serif" color="0000FF" >// array of arrays of seasons</FONT></I><BR>
|
||
|
boost::array<boost::array<std::string,4>,2> seasons_i18n = {<BR>
|
||
|
{ { { "spring", "summer", "autumn", "winter", } },<BR>
|
||
|
{ { "Fruehling", "Sommer", "Herbst", "Winter" } }<BR>
|
||
|
}<BR>
|
||
|
};<BR>
|
||
|
<BR>
|
||
|
<I><FONT face="Arial,Helvetica,sans-serif" color="0000FF" >// for any array of seasons print seasons</FONT></I><BR>
|
||
|
for (unsigned i=0; i<seasons_i18n.size(); ++i) {<BR>
|
||
|
boost::array<std::string,4> seasons = seasons_i18n[i];<BR>
|
||
|
for (unsigned j=0; j<seasons.size(); ++j) {<BR>
|
||
|
std::cout << seasons[j] << " ";<BR>
|
||
|
}<BR>
|
||
|
std::cout << std::endl;<BR>
|
||
|
}<BR>
|
||
|
<BR>
|
||
|
<I><FONT face="Arial,Helvetica,sans-serif" color="0000FF" >// print first element of first array</FONT></I><BR>
|
||
|
std::cout << "first element of first array: "<BR>
|
||
|
<< seasons_i18n[0][0] << std::endl;<BR>
|
||
|
<BR>
|
||
|
<I><FONT face="Arial,Helvetica,sans-serif" color="0000FF" >// print last element of last array</FONT></I><BR>
|
||
|
std::cout << "last element of last array: "<BR>
|
||
|
<< seasons_i18n[seasons_i18n.size()-1][seasons_i18n[0].size()-1]<BR>
|
||
|
<< std::endl;<BR>
|
||
|
}<BR>
|
||
|
<BR>
|
||
|
</SPAN>
|
||
|
</TT>
|
||
|
</BODY>
|
||
|
</HTML>
|