Here is my code:
Movies MovieManagerUI::getMovie(){
std::string code;
std::cout << "Enter Movie Code: ";
std::cin >> code;
std::cout << code;
std::string title;
std::cin.ignore();
std::cout << "Enter Movie Title: ";
std::getline(std::cin, title);
std::cout << title;
Movies thisMovie;
thisMovie.setMovieCode(code);
thisMovie.setMovieName(title);
thisMovie.setRentCount(0);
return thisMovie;
}
The program exits before it can print title. I have also tried using cin instead of getline, but I run into the same issue. If I switch the order of the two inputs (use getline first and then cin), or use cin for both or getline for both, I also run into the same issue, where whichever variable is being done second does not print onto the console, and the entire program terminates with an error code.
Why is this happening?