[404218]: / Code / C++ / C++ Tutorial Source Files / 38_C++_GettersSetters.cpp

Download this file

26 lines (21 with data), 511 Bytes

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
#include <iostream>
using namespace std;
class Movie {
public:
string title;
string director;
string rating;
Movie(string aTitle, string aDirector, string aRating){
title = aTitle;
director = aDirector;
rating = aRating;
}
};
int main()
{
Movie avengers("The Avengers", "Joss Whedon", "PG-13");
cout << avengers.rating << endl;
cout << avengers.director << endl;
cout << avengers.title << endl;
return 0;
}