How to put different objects into vector?

For my upcoming project in my computer science class, we have to make a star wars quiz game. Here is the project description:

The file star_wars.txt contains characters' names and the episode they first appeared in (this is chronological based on the release date - 4,5,6,1,2,3). You will populate a vector called cast with the contents of star_wars.txt. The cast vector is of type Character. The class Character has attributes matching the star_wars.txt file: first name, last name, episode. The program will ask the user what episode the character first appeared in. Tell the user if they are correct or incorrect. Keep track of how many they get correct, and give them a ranking based on their score.

Example of star_wars.txt:
Admiral Ackbar 6
Lando Calrissian 5
etc...

Can anyone help me with how I would put this file into a vector and display only the first and last name when asking the question? Any help would be GREATLY appreciated.

Here is what I have so far:
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
#include<iostream>
#include<vector>
#include<string>
#include<fstream>
using namespace std;

class Character
{
  private:
    int score;
    
    
    int episode;
    int guess;
  public:
    void readIn(vector<Character>&cast);
    void readOut();
    string first;
    string last;
};


int main()
{
  Character ch; 
  vector<Character> cast; 
  cout<<"Welcome to the star wars quiz! I will tell you a character and you have to tell me what episode they first appeared in. Lets play!"<<endl;
  ch.readIn(cast); 
  cout<<ch.first<<endl;


  return 0;
}

void Character::readIn(vector<Character>&cast)
{
  ifstream myFile("star_wars.txt");
  
  while ( !myFile.eof() )
  {
    myFile>>first;
  }
}
Topic archived. No new replies allowed.