Define a class named Movie. Include private fields for the title, year, and name of the director.
Include three public functions with the prototypes
void Movie::setTitle(string);
void Movie::setYear(int);
void Movie::setDirector(string);
#include <iostream>
class Movie
{
std::string title_;
int year_;
std::string directorName_;
public:
Movie() : year_(0)
{
}
void setTitle(std::string title)
{
title_ = title;
}
void setYear(int year)
{
year_ = year;
}
void setDirector(std::string directorName)
{
directorName_ = directorName;
}
};
int main()
{
Movie movie;
movie.setTitle ("The Matrix");
movie.setYear (1999);
movie.setDirector("The Wachowskis");
return 0;
}
Comments