Hi 🖐️ I am Avinash.
- Welcome to my blog. I write about software here.
- I write about math here.
Hi 🖐️ I am Avinash.
The Problem Say we have a class ParkingSlot with method Park(). Outside the class, this method should only be accessible to another class ParkingLot. How do we implement this? One (really lazy) way is to make the method private and declare the other class a friend. class ParkingSlot { // omitting other private members void Park(Vehicle *vehicle); friend class ParkingLot; public: // omitting public members }; This works, but now the friend class can access all other private members....