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 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72
|
#include <iostream>
#include <string>
using namespace std;
struct MovieData
{
string m, n, o, p;
MovieData (string, string, string, string);
};
//Make a constructor
MovieData::MovieData (string a, string b, string c, string d) {
m = a;
n = b;
o = c;
p = d;
}
void printinfo (MovieData Q)
{
cout<<"\nHere is the Movie Data:\n";
cout<<"Title: "<<Q.m<<endl;
cout<<"Director: "<<Q.n<<endl;
cout<<"Year Released: "<<Q.o<<endl;
cout<<"Running Time: "<<Q.p<<endl;
}
int main()
{
string title;
string direct;
string yearR;
string runningT;
//getmovie data
cout<<"Enter title of movie:"<<endl;
cin>>title;
cout<<"Enter the Director of movie:"<<endl;
cin.ignore();
getline(cin, direct);
cout<<"Enter the year movie was released:"<<endl;
cin>>yearR;
cout<<"Enter how long the movie is in minutes:"<<endl;
cin>>runningT;
MovieData moviea(title, direct, yearR, runningT); //defines variables at moment of creation
cout<<"Enter title of movie:"<<endl;
cin>>title;
cout<<"Enter the Director of movie:"<<endl;
cin.ignore();
getline(cin, direct);
cout<<"Enter the year movie was released:"<<endl;
cin>>yearR;
cout<<"Enter how long the movie is in minutes:"<<endl;
cin>>runningT;
MovieData movieb(title, direct, yearR, runningT);
//Call function to Display the results.
printinfo (moviea);
printinfo (movieb);
return 0;
}
|