Array Help!

In my program assignment, I have to write a template sort routine using insertion sort algorithm. Then I have to test using array of primitives, and an array of a type I create. I have finished my code, and it works correctly with arrays of primitive types, but I'm not exactly sure what it means to have an array of a type you create. Can anyone help me out here??

It means that if I have, for instance,
1
2
3
4
5
6
7
8
struct MyInt
{
    int value;
    bool operator<(const MyInt& other) const
    {
        return value < other.value;
    }
};
then your function should be able to sort an array of MyInts.
Well, it meas an array of any user defined type:
1
2
3
SomeClass arr[20];
//Initialize arr
InsertionSort(arr, arr + 20);//Or however you call your routine 

You should create Some class and make sure that it have proper copy constructor, assigment operator, defined comparsion function (for default sorting it is usually <) and whichever requirement your function places on passed types.
@long double main and @MiiNiPaa thank you!
Topic archived. No new replies allowed.