ProgrammingAssignment-CheckedArray

ProgrammingAssignment-CheckedArray - Programming Assignment...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
Programming Assignment #2 Submit file - Due Thursday, February 15, 2007 at 10:30 am Hardcopy - Due same day at the start of class This assignment gives you some experience implementing APIs by creating one for a dynamic array. The interface will be somewhat similar to the STL std::vector , but much simpler. The array will be able to grow at runtime to accommodate any number of elements. The client code does not have to worry about the array becoming full, as it never will. The task is to implement a templated class named CheckedArray which clients can use as an array of any type. The term “checked” means that your class will detect invalid indices and throw an appropriate exception if the client attempts to use an invalid index. The public interface for the CheckedArray class is straight-forward and models many of the methods in the std::vector class. The partial class definition is below: template <typename T > class CheckedArray { private : T *array_; // The dynamically allocated array unsigned int size_; // The number of elements in the array unsigned int capacity_; // The allocated size of the array // Other private fields and methods public : CheckedArray( void ); CheckedArray( const CheckedArray& rhs); CheckedArray( const T *from, unsigned size); ~CheckedArray(); operator =( const CheckedArray& rhs); T operator []( unsigned index) const throw (std::out_of_range); T& operator []( unsigned index) throw (std::out_of_range); void insert( const T& value, unsigned index) throw (std::out_of_range); T remove( unsigned index) throw (std::out_of_range); void push_back( const T& value); void push_front( const T& value); void pop_front( void ); void pop_back( void ); void clear( void ); void pack( void ); int find( const T& value) const ; bool empty( void ) const ; unsigned size( void ) const ; unsigned
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 2
This is the end of the preview. Sign up to access the rest of the document.

This lab report was uploaded on 04/18/2008 for the course CS 280 taught by Professor Mead during the Spring '07 term at DigiPen Institute of Technology.

Page1 / 2

ProgrammingAssignment-CheckedArray - Programming Assignment...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online