BELOW IS WHAT I HAVE SO FAR...IT WILL COMPILE, BUT WHEN I DEBUG, IT SAYS THAT "YEAR" HAS NOT BEEN INITIALIZED. i HAVE TRIED EVERYTHING...BEEN THRU THE BOOK, TRIED GOOGLE-ING THE ANSWER...HARDEST CLASS I HAVE TAKEN WITH A PROFESSOR WHO DOES NOT EXPLAIN OR TEACH. DONT EVEN REALLY KNOW WHAT I AM DOING. HELP PLEASE?
The directions were to define a class named Movie. Include private fields for title, year and director. Include 2 public functions with the below prototypes. Include another function to display all information. Write a main()function that declars movie object named myFavoriteMovie. Set and display object's fields.
#include<iostream>
#include<string>
using namespace std;
class Movie
{
private:
string Title;
int Year;
string Director;
public:
void setTitle(string);
void setYear(int);
void setDirector(string);
void display();
};
void Movie::setTitle(string movieTitle)
{
Title = movieTitle;
}
void Movie::setYear(int num)
{
while(Year < 2013)
++Year;
}
void Movie::setDirector(string Dir)
{
Director = Dir;
}
void Movie::display()
{
cout << Title << Year << Director << endl;
}
int main()
{
Movie myFavoriteMovie;
string Title;
int Year;
string Director;
cout << Title << Year << Director << endl;
myFavoriteMovie.setTitle(Title);
myFavoriteMovie.setYear(Year);
myFavoriteMovie.setDirector(Director);
myFavoriteMovie.display();
return 0;
}