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

Class Array

Examples/NoModules/Chapter 18/Ex18_06/Array.h:22–41  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected