Here's the problem, questions at the bottom.
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.
I'm given
// Chapter 7 - Assignment 1, Movie Data
// This program stores movie information in a structure.
// The structure is passed to a function to display the data.
#include <iostream>
#include <string>
using namespace std;
// --------------------------------
// ----- ENTER YOUR CODE HERE -----
// --------------------------------
// --------------------------------
// --------- END USER CODE --------
// --------------------------------
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;
}
I've got a question right here. movie1 and movie2 are both variables no?(Cannot find an example of this in my book) It looks like a function there being parenthesis. How does it work?
what my structure looks like right now
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;
}
};
My display message function
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;
}
Am I along the right tracks or am I doing something totally wrong? I missed class this week and so I'm having a hard time grasping what I'm supposed to do. What am I doing wrong and what do i need to do to get this running. I've been messing around and looking through my book to understand how it works and no luck so far. Hints would be helpful