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

Class Array

Exercises/NoModules/Chapter 21/Soln21_06/Array.h:35–54  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

33
34template <typename T>
35class Array
36{
37public:
38 Array(); // Default constructor
39 explicit Array(size_t size); // Constructor
40 ~Array(); // Destructor
41 Array(const Array& array); // Copy constructor
42 Array(Array&& array) noexcept; // Move constructor
43 Array& operator=(const Array& rhs); // Copy assignment operator
44 Array& operator=(Array&& rhs) noexcept; // Move assignment operator
45 void swap(Array& other) noexcept; // Swap member function
46 T& operator[](size_t index); // Subscript operator
47 const T& operator[](size_t index) const; // Subscript operator-const arrays
48 size_t getSize() const { return m_size; } // Accessor for m_size
49 void push_back(T element); // Copy or move element to the back of the array
50
51private:
52 T* m_elements; // Array of type T
53 size_t m_size; // Number of array elements
54};
55
56// Forwarding default constructor template
57template <typename T>

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected