#include <cstdio>
#include <cstdlib>
#include <cassert>
#include <cstring>
#define Array(type, name, n) array <type> name(n, __LINE__)
template <class T>
struct array
{
int n, line;
T *a;
array( int _n = 0, int _line = -1 )
{
n = _n, line = _line;
a = new T[n];
memset(a, 0, sizeof(T) * n);
}
~array()
{
delete [] a;
}
inline T & operator [] ( int i )
{
if (!(0 <= i && i < n))
{
fprintf(stderr, "RANGE CHECK ERROR: n=%d i=%d (array was allocated at line %d)\n", n, i, line);
fflush(stderr);
exit(1);
}
return a[i];
}
};
int main()
{
Array(int, a, 8);
for (int i = 0; i < 11; i++)
{
a[i] = 2;
printf("%d\n", i);
}
return 0;
}