#include <iostream>
using namespace std;
#define SIZE (1)
struct arry
{
int *n = NULL;
int size;
arry() { n = new int[SIZE]; size = SIZE; }
~arry() { delete [] n; }
void incSize() {
int *temp = new int[size + 1];
for (int i = 0; i < size; ++i) {
temp[i] = n[i];
}
delete [] n;
n = temp;
size++;
}
};
int main() {
int a[10];
int b[99];
int *c = new int[77];
cout << "sizeof a = " << sizeof a << endl;
cout << "(sizeof a) / sizeof(int) = " << (sizeof a) / sizeof(int) << endl;
cout << "sizeof b = " << sizeof b << endl;
cout << "(sizeof b) / sizeof(int) = " << (sizeof b) / sizeof(int) << endl;
cout << "sizeof c = " << sizeof c << endl;
cout << "(sizeof c) / sizeof(int) = " << (sizeof c) / sizeof(int) << endl;
cout << "sizeof *c = " << sizeof *c << endl;
cout << "(sizeof *c) / sizeof(int) = " << (sizeof *c) / sizeof(int) << endl;
cout << "動的に確保された配列のサイズはsizeofでは取得できないのだよ" << endl;
cout << endl << "可変配列のテスト" << endl;
arry dyn;
dyn.n[0] = 100;
cout << sizeof dyn.n << endl;
cout << dyn.size << endl;
dyn.incSize();
cout << sizeof dyn.n << endl;
cout << dyn.size << endl;
dyn.n[1] = 200;
cout << dyn.n[0] << endl;
cout << dyn.n[1] << endl;
return 0;
}