Exercise 6.1

Rewrite the following class definition to make it a class template:

					class example {
					public:
					example( double min, double max );
					example( const double *array, int size );
					double& operator[]( int index );
					bool operator==( const example1& ) const;
					bool insert( const double*, int );
					bool insert( double );
					double min() const { return _min; }
					double max() const { return _max; }
					void min( double );
					void max( double );
					int count( double value ) const;
					private:
					int     _size;
					double *_parray;
					double  _min;
					double  _max;
					};
				

To transform the example class into a template, we must identify and factor out each dependent data type. _size, for example, is of type int. Might that vary with different user-specified instances of example? No. _size is ...

Get Essential C++ now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.