View Single Post
Old 07-07-2004, 02:48 PM   #8 (permalink)
Valmont
[code][/code] enforcer
 
Valmont's Avatar
 
Join Date: Mar 2003
Location: Netherlands
Posts: 1,544
Valmont is on a distinguished road
Templates mate. Templates.
Code:
template <typename T> class MyArrayClass
{
public:
	MyArrayClass( int arraySize ); 
private:
	int size; 
	T* array; 

}
And below is how you could define a setItem method:
Code:
void dInt::setItem(  int pos, T val )
	{
		if(pos <= size)	
			array[pos] = val;
	}
And so forth. But I warn you, setting up a decent abstract array is hard .
For example, what do you have to do to make this always work?
Code:
array[pos] = val;
Try it if you like a challenge .
__________________

Last edited by Valmont; 07-08-2004 at 04:41 PM.
Valmont is offline   Reply With Quote