Help with Abstact data type

I have written the code below to manage a DVD library. and array of 10 DVDs are created, with variables inputted from txt file.

I have found a way to then print out all of the information
My question is: if I only want to display one of the multidimensional arrays.
Ideally, i would have prompt the user to enter the rentalID to identify the particular element.


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
  #include <iostream>
#include <fstream>
#include <string>

using namespace std;

class DVDdata{
public:
    int rentalID;
    string title;
    int year;
    string director;
    string starring;
    double rating;
    string availability;

};

int main()
 {
    DVDdata DVDlib[10];   // creating an array of 10 abstract data types "DVDdata". Name the array DVDlib

   ifstream DVDstream("10DVDS.txt");
   int count=0;

   while(DVDstream >> DVDlib[count].rentalID >>DVDlib[count].title >> DVDlib[count].year >>DVDlib[count]. director >>DVDlib[count]. starring >>DVDlib[count]. rating >> DVDlib[count].availability)
    {
      cout << "Tile: " << DVDlib[count].title << endl;
      cout << " Released in: " <<DVDlib[count]. year << endl;
      cout << " directed by: " << DVDlib[count].director << endl;
      cout << " starring: " <<DVDlib[count]. starring << endl;
      cout << " IMDB rating: " << DVDlib[count].rating << endl;
      cout << " Available? : " << DVDlib[count].availability << endl;
       ++count;
    }
  }



Thanks!
Topic archived. No new replies allowed.