Hi
Im pretty new to the whole C++ programming language but after learning python and java i decided to give it a go. I have been using tutorials at www.cplusplus.com and that has been working fine but i came across a bit of code today i couldn't understand. It went like this:
// 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";
}
My problem is where is goes void printmovie (movies_t movie);
and there is nothing after it and then later in the program is does the same thing again but this time there is an actual function defined. My question is, why would the person who made this have put that void printmovie (movies_t movie);
without having any actual code defined until way later in the program.
Thanks. :)