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

Class Array

Examples/NoModules/Chapter 17/Ex17_02/Array.h:9–24  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected