Example of Encapsulation in D
Let’s see how encapsulation works with the help of an example.
We'll cover the following...
Encapsulation example
Let’s define the Student
struct and the School
class by taking advantage of encapsulation, and let’s use them in a short test program.
This example program will consist of three files. As you remember from the previous chapter, being parts of the school package, two of these files will be under the “school” directory: