Sem2 task1 fix size bug

This commit is contained in:
Inex Code 2020-09-21 08:11:39 +00:00
parent 37c86de8ad
commit 126e8e2e0f

View file

@ -66,13 +66,16 @@ public:
} }
DynArr(uint dsize) DynArr(uint dsize)
{ {
arr = new int(dsize); arr = new int[dsize];
size = dsize; size = dsize;
for (uint i = 0; i < size; i++) {
arr[i] = rand() % 100;
}
} }
DynArr(const DynArr& original) DynArr(const DynArr& original)
{ {
size = original.size; size = original.size;
arr = new int(original.size); arr = new int[original.size];
memcpy(arr, original.arr, sizeof(int) * size); memcpy(arr, original.arr, sizeof(int) * size);
} }
~DynArr() ~DynArr()