Don't understand data structures...

While I was learn in the C++ tutorials here, I didn't understand a snippet of code given in the data structure section.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
// example about structures
#include <iostream>
#include <string>
#include <sstream>
using namespace std;

struct movies_t {
  string title;
  int year;
} mine, yours;

void printmovie (movies_t movie);

int main ()
{
  string mystr;

  mine.title = "2001 A Space Odyssey";
  mine.year = 1968;

  cout << "Enter title: ";
  getline (cin,yours.title);
  cout << "Enter year: ";
  getline (cin,mystr);
  stringstream(mystr) >> yours.year;

  cout << "My favorite movie is:\n ";
  printmovie (mine);
  cout << "And yours is:\n ";
  printmovie (yours);
  return 0;
}

void printmovie (movies_t movie)
{
  cout << movie.title;
  cout << " (" << movie.year << ")\n";
}

I understand basically everything except for these lines.
 
void printmovie (movies_t movie)


In the parameters, what is (movies_t movie)? movies_t is ok, but what's with the extra "movie"? Sorry if you super smart programmers think this is a stupid question, but I just want to try to see what that part is.
Last edited on
movies_t movie is the data type of the argument/parameter. Just like how you can pass an integer like:

 
void display (int number)


int is the data type, and number is the name.

movies_t is the data type and movie is the name.

Make sense?
Topic archived. No new replies allowed.