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 38 39 40 41 42 43 44
|
#include <iostream>
using namespace std;
struct Array
{
int arr[10];
Array(int * a)
{
for (int i=0; i<10; i++) arr[i]=a[i];
}
};
class A
{
public:
A(int * a):array(a){}
~A(){}
//private:
const Array array;
};
int main()
{
int arr1[10]={1,2,3,4,5,6,7,8,9,10};
int arr2[10]={1,3,5,7,9,-2,-4,-6,-8,-10};
A a(arr1);
A b(arr2);
int i;
for (i=0; i<10; i++)
cout << a.array.arr[i] << ' ';
cout << endl;
for (i=0; i<10; i++)
cout << b.array.arr[i] << ' ';
cout << endl;
cout << "hit enter to quit..." << endl;
cin.get();
return 0;
}
|