Hi guys, I'm trying to learn more about the power of using vectors as containers, however I've run into some problems when trying to create a bubble sort algorithm.
I think I'm on the right track, but I have a problem, the container vector is holding track of a struct SMovie, which looks like this:
Code:
struct SMovie
{
string Title;
string Year;
string Director;
string Description;
};
And I'm not sure how I should link them so they can be exchangable, because using this method; causes illegal indirection error:
Code:
void CContainer::Sort()
{
// Sorts all the items by title name within the vector, with the help of the bubblesort algorithm
for(iter = Container.begin(); iter < Container.end(); ++iter)
{
for(iter2 = Container.begin(); iter2 < Container.end(); ++iter2)
{
if(iter < iter2)
{
iter_swap((*iter),(*iter2));
}
}
}
};
Anyone?