Learn about encapsulation in this lesson.

We'll cover the following


All of the structs and classes we have defined so far have been accessible from the outside (main() and other functions in the program).

Let’s consider the following struct:

enum Gender { female, male }

struct Student {
    string name;
    Gender gender;

The members of that struct are freely accessible to the rest of the program:

Create a free account to view this lesson.

By signing up, you agree to Educative's Terms of Service and Privacy Policy