Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #pragma once
- #include <fstream>
- #include <iostream>
- using namespace std;
- class Array
- {
- int* data;
- int count;
- public:
- Array()
- {
- int size = 0;
- cin >> size;
- data = new int[size];
- for (int i = 0; i < size; i++)
- {
- cin >> data[i];
- }
- count = size;
- cout << "CREATED" << endl;
- }
- ~Array()
- {
- delete[] data;
- cout << "DELETED" << endl;
- }
- Array remove(int id)
- {
- int* newarray = new int[count - 1];
- for (int i = 0; i < count - 1; i++)
- {
- if (i < id)
- newarray[i] = data[i];
- else
- newarray[i] = data[i - 1];
- }
- delete[] data;
- return newarray;
- }
- Array(const Array& o)
- {
- data = new int[o.count];
- for (int i = 0; i < o.count; i++)
- {
- data[i] = o.data[i];
- }
- count = o.count;
- }
- void print()
- {
- for (int i = 0; i < count; i++)
- {
- cout << data[i] << "; ";
- }
- cout << endl;
- }
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement