Vector not displaying correctly

I am having problems with the output.

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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
using namespace 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()
{
	const int 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.


1
2
Catwoman     109      2003     Halle Berry    Catwoman
                               The Man
Last edited on
Topic archived. No new replies allowed.