Answer to Question #261949 in C++ for umer

Question #261949

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);


1
Expert's answer
2021-11-06T11:48:33-0400
#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;    
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS