Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- using namespace std;
- class Example {
- int* array;
- size_t size;
- public:
- Example(const Example& other) {
- cout << "Copeid";
- size = other.size;
- array = new int[size];
- for (int i = 0; i < size; i++)
- array[i] = other.array[i];
- }
- Example(const int& size)
- {
- cout << endl << "Created" << endl;
- this->size = size;
- array = new int[size];
- for (size_t i = 0; i < size; i++)
- array[i] = 0;
- }
- ~Example()
- {
- cout << endl << "Deleted" << endl;
- delete[] array;
- }
- void fill() {
- cout << "Fill array:" << endl;
- for (size_t i = 0; i < size; i++) {
- cout << i + 1 << "] ";
- cin >> array[i];
- }
- cout << endl;
- }
- };
- void func(Example obj) {
- }
- int main()
- {
- size_t N;
- cout << "Enter N: ";
- cin >> N;
- Example example(N);
- example.fill();
- func(example);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement