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

Class Array

Examples/NoModules/Chapter 18/Ex18_05B/Array.h:13–32  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected