MCPcopy Create free account
hub / github.com/Apress/beginning-cpp20 / Array

Class Array

Examples/NoModules/Chapter 18/Ex18_07/Array.h:12–31  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

10
11template <typename T>
12class Array
13{
14public:
15 Array(); // Default constructor
16 explicit Array(size_t size); // Constructor
17 ~Array(); // Destructor
18 Array(const Array& array); // Copy constructor
19 Array(Array&& array) /*noexcept*/; // Move constructor
20 Array& operator=(const Array& rhs); // Copy assignment operator
21 Array& operator=(Array&& rhs) /*noexcept*/; // Move assignment operator
22 void swap(Array& other) noexcept; // Swap member function
23 T& operator[](size_t index); // Subscript operator
24 const T& operator[](size_t index) const; // Subscript operator-const arrays
25 size_t getSize() const { return m_size; } // Accessor for m_size
26 void push_back(T element); // Copy or move element to the back of the array
27
28private:
29 T* m_elements; // Array of type T
30 size_t m_size; // Number of array elements
31};
32
33// Forwarding default constructor template
34template <typename T>

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected