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

Class Array

Examples/NoModules/Chapter 17/Ex17_03/Array.h:10–26  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

8
9template <typename T>
10class Array
11{
12public:
13 explicit Array(size_t size); // Constructor
14 ~Array(); // Destructor
15 Array(std::initializer_list<T> elements); // Initializer list constructor
16 Array(const Array& array); // Copy constructor
17 Array& operator=(const Array& rhs); // Copy assignment operator
18 void swap(Array& other) noexcept; // Swap member function
19 T& operator[](size_t index); // Subscript operator
20 const T& operator[](size_t index) const; // Subscript operator-const arrays
21 size_t getSize() const { return m_size; } // Accessor for m_size
22
23private:
24 T* m_elements; // Array of type T
25 size_t m_size; // Number of array elements
26};
27
28// Constructor template
29template <typename T>

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected