#include <iostream>
#include <cstdio>
using namespace std;
class Movie
{
public:
Movie(char title, int year, int rating);
void print();
private:
char m_title;
int m_year;
int m_rating;
};
Movie::Movie(char title, int year, int rating)
{
m_year = year;
m_rating = rating;
m_title = title;
}
void
Movie::print()
{
cout << "Year: " << m_year << "," << m_title << ", rating = " << m_rating << endl;
}
int
main()
{
Movie *data[100]; // array to hold the dynamically created Pair objects
int num_movies = 0; // the number of pair objects we have created
char *title;
int year, rating; // hold values read from cin
// as long as there is an integer to read, read it (as long as not EOF)
while (cin >> title)
gets(title);
{
//read 2nd integer in pair (dangerous assumption, what if no more nums?)
cin >> year;
//
cin >> rating;
// instantiate a new Pair object using the new operator
data[num_movies] = new Movie(*title, year, rating);
// we have read another pair of integers, update our counter
num_movies++;
}
// print out all the pairs pointed to by the data array
for (int i = 0; i < num_movies; i++)
{
cout << i << endl;
data[i]->print();
}
}