void Movie::add(vector<Movie>& movies){
string addName = "";
string addDirector = "";
string addRelease = "";
string addAudience = "";
unsignedshort addRunTime = 0;
class Movie myMovie;
cout << "Adding a movie." << endl;
cout << "What is the title? ";
cin >> addName;
cout << "Who is the director? ";
cin >> addDirector;
cout << "When was it first released? ";
cin >> addRelease;
cout << "Who is the intended audience (rating)? ";
cin >> addAudience;
cout << "How long does the movie run? ";
cin >> addRunTime;
cout << "List will be updated." << endl;
myMovie.add(addName, addDirector, addRelease, addAudience, addRunTime);
movies.push_back(myMovie);
return;
} // add
However, it won't even compile:
$ g++ -Wall movie.cpp main.cpp
In file included from movie.cpp:5:
./movie.h:24:16: error: too few template arguments for class template 'vector'
void add(vector<>& unsigned short);
^
/usr/include/c++/4.2.1/bits/stl_vector.h:162:11: note: template is declared here
class vector : protected _Vector_base<_Tp, _Alloc>
Did i really declare it wrong, or is this about clang being picky?
push_back adds an element at the end of the vector, so I don't see that you need a specific index.
When you create an object of type Movie, you don't need the class keyword in front.
class Movie myMovie;
I'm not sure about where you are creating the vector of movies and the movie object you're going to add. And about having two public add functions. Right now you're creating a movie object that exists within the scope of the add function. Not sure what the assignment actually wants you to do.