Gryphon75 0 Newbie Poster

Hello everyone, this is my first post.
I am working on a school assignment and I am stuck. The assignment involves reading a file that contains course subjects and the maximum number of students that can take the class. The contents are entered into an array sorted alphabetically by the course name. We are given a function template to do the ordered insertion.
I can read the data into the array but I cannot figure out how to perform the addInOrder function. It could be that I am not using the template correctly I do not know, and I have waited for a month for some assistance. If anyone could point me in the right direction I would greatly appreciate it.

void readCourses (istream& courseFile, int numCourses,
		  string* courseNames, int* maxEnrollments)
{
  //!! Insert your code here

    int i = 0;
    for ( i = 0; i < numCourses; ++i)
    courseFile >> courseNames[i] >> maxEnrollments[i];

    //int addInOrder();
   

}

And here is the function template for addInOrder

template <typename T>
int addInOrder (T* array, int& size, T value)
{
    // Make room for the insertion
    int toBeMoved = size - 1;
    while (toBeMoved >= 0 && value < array[toBeMoved])
    {
        array[toBeMoved+1] = array[toBeMoved];
        --toBeMoved;
    }
    // Insert the new value
    array[toBeMoved+1] = value;
    ++size;
    return toBeMoved+1;
}

Thank you again.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.