Advertisement
Sanlover

Untitled

Sep 5th, 2021
112
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.87 KB | None | 0 0
  1. #include <iostream>
  2. #include <string>
  3. using namespace std;
  4.  
  5. class Example {
  6. int* array;
  7. size_t size;
  8. public:
  9. Example(const Example& other) {
  10. cout << "Copeid";
  11. size = other.size;
  12. array = new int[size];
  13. for (int i = 0; i < size; i++)
  14. array[i] = other.array[i];
  15. }
  16.  
  17. Example(const int& size)
  18. {
  19. cout << endl << "Created" << endl;
  20. this->size = size;
  21. array = new int[size];
  22. for (size_t i = 0; i < size; i++)
  23. array[i] = 0;
  24. }
  25.  
  26. ~Example()
  27. {
  28. cout << endl << "Deleted" << endl;
  29. delete[] array;
  30. }
  31.  
  32. void fill() {
  33. cout << "Fill array:" << endl;
  34. for (size_t i = 0; i < size; i++) {
  35. cout << i + 1 << "] ";
  36. cin >> array[i];
  37. }
  38. cout << endl;
  39. }
  40. };
  41.  
  42. void func(Example obj) {
  43. }
  44.  
  45. int main()
  46. {
  47. size_t N;
  48. cout << "Enter N: ";
  49. cin >> N;
  50.  
  51. Example example(N);
  52. example.fill();
  53.  
  54. func(example);
  55.  
  56. return 0;
  57. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement