So I am relatively new to C++ and I was doing a small project where I have the user enter a movie title, rating, and year. For the first run through, the program works well. After the user enters the desired information I print it back to the screen with no problem. However, when I create a second movie object to do the same thing during the same run it skips the section where it asks for the Title and goes directly to the rating. Any ideas? It's most likely a noob error. My Code is below.
MovieProject.cpp
#include "stdafx.h"
#include "Movie.h"
#include <iostream>
#include <string>
using namespace std;
int main()
{
Movie starwars;
starwars.MovieTeller(starwars);
Movie FerrisBueller;
FerrisBueller.MovieTeller(FerrisBueller);
Movie TheFoxandTheHound;
TheFoxandTheHound.MovieTeller(TheFoxandTheHound);
return 0;
}
Movie.cpp
#include "stdafx.h"
#include "Movie.h"
#include <string>
#include <iostream>
using namespace std;
Movie::Movie()
{
cout << "What is the title of your movie:";
getline(cin,Title);
cout << "What is the Rating:";
getline(cin,Rating);
cout << "What year was it made:";
cin >> Year;
cout << "\n" << endl;
if (Year > 2016) {
cout << "Comon Dude stop messing around" << endl;
exit(404);
}
}
void Movie::MovieTeller(Movie a) {
cout << "Title:" << Title << "\n" << "Rating:" << Rating << "\n" << "Year:" << Year << "\n" << endl;
}
Movie::~Movie()
{
}
Movie.h
#pragma once
#include <iostream>
using namespace std;
class Movie
{
public:
Movie();
~Movie();
void MovieTeller(Movie a);
private:
string Title;
string Rating;
int Year;
};