Advertisement
Guest User

Untitled

a guest
May 19th, 2019
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.89 KB | None | 0 0
  1. #include "Array.h"
  2. Array::Array(unsigned short init_size, unsigned char init_value)
  3. {
  4. if (init_size < 0)
  5. {
  6. std::cout << "Введена отрицательная размерность!" << '\n';
  7. system("Pause");
  8. exit(0);
  9. }
  10. if (init_size > 100)
  11. {
  12. std::cout << "Введенное количество элементов больше 100. Массив будет содержать 100 элементов" << '\n';
  13. this->size = 100;
  14. _array = new unsigned char[100];
  15. for (unsigned int i = 0; i < 100; i++)
  16. {
  17. _array[i] = init_value;
  18. }
  19. }
  20. else
  21. {
  22. this->size = init_size;
  23. _array = new unsigned char[this->size];
  24. for (unsigned int i = 0; i < size; i++)
  25. {
  26. _array[i] = init_value;
  27. }
  28. }
  29. static unsigned short count = 0;
  30. count++;
  31. }
  32.  
  33. unsigned char & Array::operator[](int i)
  34. {
  35. return _array[i];
  36. }
  37.  
  38. Array::~Array()
  39. {
  40. delete _array;
  41. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement