1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37
|
#include <iostream>
using namespace std;
struct point
{
int x, y;
point( int x, int y ): x( x ), y( y ) { }
};
ostream& operator << ( ostream& outs, const point& pt )
{
return outs << "(" << pt.x << ", " << pt.y << ")";
}
template <typename T, size_t N>
size_t sizeof_array( const T (& a) [ N ] )
{
return N;
}
int main()
{
point pts[] =
{
point( 1, 2 ),
point( 2, 3 ),
point( 3, 5 ),
point( 4, 7 ),
point( 5, 11 ),
point( 6, 13 )
};
for (unsigned n = 0; n < sizeof_array( pts ); n++)
cout << pts[ n ] << endl;
return 0;
}
|