12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455 |
- #pragma once
- #include <iostream>
- using namespace std;
- const int DEFAULT_CAPACITY = 10;
- /// <summary>
- /// An array holding some integer values
- /// </summary>
- class Array
- {
- private:
- int* ptr;
- int size, capacity;
- /// <summary>
- /// Increase the capacity of the array
- /// </summary>
- /// <param name="newCapacity">New capacity</param>
- void increaseCapacity(int newCapacity);
- public:
- explicit Array(int startCapacity = DEFAULT_CAPACITY);
- Array(const Array&);
- ~Array();
- Array& operator = (const Array& arr);
- int& operator [] (int index);
- /// <summary>
- /// Insert element into position
- /// </summary>
- /// <param name="elem">The value to be inserted</param>
- /// <param name="index">The position to insert the value into</param>
- void insert(int elem, int index);
- /// <summary>
- /// Remove element from array
- /// </summary>
- /// <param name="index">The index of the element to be removed</param>
- void remove(int index);
- /// <summary>
- /// Get current size of the array
- /// </summary>
- /// <returns>The size of the array</returns>
- int getSize() const;
- friend ostream& operator <<(ostream& out, const Array& arr);
- };
|