commit a0967cba2c1faa6714988b08369e59268aaee023 parent 8f992243e63bb1dc5b6c3cca01917364ae131e22 Author: Michael Savage <mikejsavage@gmail.com> Date: Sun Nov 13 17:50:46 +0200 Make array copyable Diffstat:
array.h | | | 14 | +++++++++++--- |
diff --git a/array.h b/array.h @@ -8,8 +8,13 @@ template< typename T > class array { public: - array( T * memory, size_t count ) : n( count ), bytes( sizeof( T ) * count ) { + array() { + n = 0; + } + + array( T * memory, size_t count ) { ASSERT( memory != NULL ); + n = count; elems = memory; } @@ -41,8 +46,11 @@ public: return elems; } - const size_t n; - const size_t bytes; + size_t bytes() const { + return sizeof( T ) * n; + } + + size_t n; private: T * elems;