#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
usingnamespace std;
class DVD
{
private:
string movieTitle;
string name;
string charName;
double movieLength;
int movieYear;
public:
DVD(){}
DVD(string n)
{ name = n; }
void setTitle(string t)
{ movieTitle = t; }
void setLength(double l)
{ movieLength = l; }
void setYear(int y)
{ movieYear = y; }
string getName()
{ return name; }
string getTitle()
{ return movieTitle; }
double getLength()
{ return movieLength; }
int getYear()
{ return movieYear; }
};
int main()
{
constint ARRAY = 2;
DVD mydvd[ARRAY];
vector<DVD> vectorName;
vector<string> vectorCharName;
vector<DVD> vectorList;
string actor, character, title;
double length;
int year;
int quantity; // To hold number of actors
for(int i = 0; i < 1; i++)
{
cout << "DVD " << (i+1);
cout << " enter the details.";
cout << "\nMovie Title: ";
getline(cin, title);
mydvd[i].setTitle(title);
cout << "\nMovie Length: ";
cin >> length;
mydvd[i].setLength(length);
cout << "\nMovie Year: ";
cin >> year;
mydvd[i].setYear(year);
cout << endl;
cout << "How many actors? ";
cin >> quantity;
for (int i = 0; i < quantity; i++)
{
cout << "Actor " << (i+1) << ": ";
cin.ignore();
getline(cin, actor); // get user input
cout << "Character " << (i+1) << ": ";
getline(cin, character); // get user input
vectorName.push_back(actor);
vectorCharName.push_back(character);
}
}
// Display The list of movies
for (int i = 0; i < 1; i++)
{
cout << setw(10) << left;
cout << mydvd[i].getTitle()<< setw(10) << left
<< mydvd[i].getLength()<< setw(10) << left
<< mydvd[i].getYear()<< setw(10) << left;
for (int i= 0; i < vectorName.size(); i++)
{
cout << vectorName[i].getName()<< setw(10)
<< vectorCharName[i] << endl << setw(30);
}
}
cout << endl;
system("pause");
}
Here is the output. Can someone tell my why it won't display the other Actors I entered? I entered Morgan Freeman as actor number 2... But is doesn't display it and it puts his character name in the Actor name spot.