A program that I'm creating in a c++ intro class is confusing me. The question is this, and right below is the main function it gives me
Write a program that uses a structure named MovieData to store the following information about a movie:
Title
Director
Year Released
Running time (in minutes)
Include a constructor that allows all 4 of these member data values to be specified at the time a MovieData variable is created. The program should create two MovieData variables and pass each one, in turn, to a function that displays the information about the movie in a clearly formatted manner.
1 2 3 4 5 6 7 8 9 10
|
int main()
{
MovieData movie1("War of the Worlds", "Byron Haskin", 1953, 88),
movie2("War of the Worlds", "Stephen Spielberg", 2005, 118);
displayMovie(movie1);
displayMovie(movie2);
return 0;
}
|
First of all, movie1() and movie2() are supposed to be variables with multiple/different data types, is that correct? Every example in my book has a variable in that place and I cannot find what that is made like this one is above.
My display function looks like this
1 2 3 4 5 6 7 8 9 10
|
void displayMovie()
{
string title,
director;
int year, time;
cout << "Title : " << title << endl;
cout << "Director : " << director << endl;
cout << "Year Released: " << year << endl;
cout << "Running time : " << time << endl;
|
Is that correct?
My structure, which I'm really unsure of, looks like this
1 2 3 4 5 6 7 8 9 10 11 12 13 14
|
struct MovieData
{
string title,
director;
int year,
time;
MovieData(string t, string d, int y, int t2)
{ title = t,
director = d,
year = y,
time = t2;
}
};
|
I'm mainly going off what examples show.
What all is wrong and what more do I need to do or change?