error: too few template arguments for class template 'vector'

I'm still in first semester here, and i don't know how fix the error given in the title.

here is the relevant part of movie.h:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
class Movie{
   public:
      Movie();
      void add(vector<>& unsigned short);
      void add(string, string, string, string, unsigned short);
      void delet(int);
      void display(int);
      void loan(int);
   private:
      string name;
      string director;
      string release;
      string audience;
      unsigned short runtime;
};


here is the relevant part of movie.cpp:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
void Movie::add(vector<Movie>& movies){
   string addName = "";
   string addDirector = "";
   string addRelease = "";
   string addAudience = "";
   unsigned short 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?
Do you mean to have just one parameter here of type vector<Movie>? The definition just has one parameter. What's the unsigned short in the prototype?

1
2
void add(vector<>& unsigned short);
void Movie::add(vector<Movie>& movies){
The unsigned short is the index of the vector, which i thought needs to be included when an array or vector is passed. Is it not needed?
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.
Topic archived. No new replies allowed.