40. Getting Started with C++: Friend

Опубликовано: 22 Февраль 2023
на канале: Ognema's Tech Lab
4
0

In C++, the friend keyword allows a non-member function or class to access the private and protected members of a class. This means that the friend function or class has access to the private or protected data of the class as if it were a member function or class.

In this way, friend functions or classes can provide additional functionality to a class without exposing its implementation details or breaking encapsulation. This is useful when you need to manipulate the internal state of a class or access private data, but don't want to make the data public or provide accessors for each piece of private data.