C actual combat: realization of a light array class
Description: This array class can be considered as a simplified version of the vector library: supporting the general operation of array, supporting copy, assignment, supporting the redefine size; do not consider multithreading, regardless of pre-allocation extra space, performance optimization, no Set an iterator.
#include
Template
Array (size tty = type ()); // You can specify the initial size with size, T specify the initial value array (const array & array); ~ array (); // space is automatically released
TYPE & OPERATOR [] (SIZE_TP INDEX); // Upload Access (Read / Write Form) Const Type & Operator [] (SIZE_TP INDEX) Const; / / Subscriber Access (read-only) Array & Operator = (Const Array & RHS); // Assignment, change the size / content
SIZE_TP GET_SIZE () const; // Get array size void resize (size_tp size); // Reset an array size, if you change, drop the tail data
Void Push_Back (const type & value); // Add an array element, an array size increases
PRIVATE: VOID COPY (const type * p_source, type * p_target, size_tp size); size_tp _size; type * _arr;};
Template Template Template Template Template Template Template Template Template INT Main () // Main Test Function {Array