Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "Array.h"
- Array::Array(unsigned short init_size, unsigned char init_value)
- {
- if (init_size < 0)
- {
- std::cout << "Введена отрицательная размерность!" << '\n';
- system("Pause");
- exit(0);
- }
- if (init_size > 100)
- {
- std::cout << "Введенное количество элементов больше 100. Массив будет содержать 100 элементов" << '\n';
- this->size = 100;
- _array = new unsigned char[100];
- for (unsigned int i = 0; i < 100; i++)
- {
- _array[i] = init_value;
- }
- }
- else
- {
- this->size = init_size;
- _array = new unsigned char[this->size];
- for (unsigned int i = 0; i < size; i++)
- {
- _array[i] = init_value;
- }
- }
- static unsigned short count = 0;
- count++;
- }
- unsigned char & Array::operator[](int i)
- {
- return _array[i];
- }
- Array::~Array()
- {
- delete _array;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement