Hello, I am doing a homework assignment for my C++ course at university. For this assignment, I have a text file of movie ratings. For each movie, the first line is the number of ratings, the second is the title of the movie and the third is the average rating out of 5 stars.
An example of one of the movie ratings in the text file:
10
Harry Potter and the Order of the Phoenix
4
For this assignment, I have to use std::map to store all of the reviews, where the key is the movie title and it contains a pair with the number of reviews and the average review. I also must incorporate an iterator into the solution.
Here is file with the main function:
#include <iostream>
#include <fstream>
#include "MovieCritic.h"
int main()
{
std::ifstream file("movies.txt");
if (!file.is_open())
{
std::cerr << "Error opening the file!";
return 1;
}
MovieCritic list;
file >> list;
file.close();
std::cout << "Movie Ratings: " << std::endl;
std::cout << list;
return 0;
}