Hey man, it is C++ and you far better alternatives to arrays and bubble sort.
#include <vector>
#include <algorithm>
#include <iostream>
#include <string>
using namespace std;
class Movie
{
private:
string name;
string director;
public:
Movie(string n="Movie", string d="Director"):name(n), director(d){}
void setName(string n)
{
name = n;
}
void setDirector(string d)
{
director = d;
}
const string getName() const
{
return name;
}
const string getDirector() const
{
return director;
}
};
ostream & operator << (ostream & os, const Movie & movie)
{
os << movie.getName();
return os;
}
int main()
{
vector< Movie > mv{ Movie("Foo", "boo"), Movie("Goo"), Movie("AAA", "BBB")};
cout << "list of movies: ";
for ( const auto & m : mv)
cout << m << " ";
cout << endl;
sort( mv.begin(), mv.end(), [](const Movie & m1, const Movie & m2) {return (m1.getName() < m2.getName());});
cout << "sorted list of movies: ";
for ( const auto & m : mv)
cout << m << " ";
cout << endl;
}