Answer to Question #246476 in C++ for Boo

Question #246476
Define a class named Person that contains the data fields for the first name and last name.
Include only a non-default constructor that that initializes the data fields and a method that
displays all the information about a Person.
Define another class named Movie that stores a title, year of production and director’s
information. Director should be a Person member-object (i.e. composition). Include a non-
default constructor and a function to display Movie information.
Write a main() method that creates two Movie objects, and displays information about the
Movie objects
1
Expert's answer
2021-10-04T07:51:29-0400
#include<iostream>
using namespace std;
class Person{
	private:
		string first_name, last_name;
	public:
		Person(){
			first_name = "Robert";
			last_name = "Brown ";
		}
		void display(){
			cout<<"First Name:  "<<first_name<<endl;
			cout<<"Last Name:  "<<last_name<<endl;


		}
};
class Movie{
	private:
	 string	title;
	 int  yearOfProduction;
	 Person director;
	public:
	 Movie(){
	 	title = "Spartacus";
	 	yearOfProduction = 2021;
	 	
	 	
	 }
	 void output(){
	 	director.display();
	 		cout<<"Title:  "<<title<<endl;
			cout<<"Year of production:  "<<yearOfProduction<<endl;
	 	
	 }
};
int main(){
	Movie m;
	m.output();
}

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