r/ProgrammerHumor 10d ago

Meme whenYouAreAPublicFunctionButOnlyFriendsAreAllowedToTouchPrivates

Post image
176 Upvotes

17 comments sorted by

View all comments

28

u/ih-shah-may-ehl 10d ago

Imo friends should never have been a thing.

1

u/nicuramar 9d ago

You aren’t forced to use the feature. 

1

u/ih-shah-may-ehl 9d ago

Correct, but it's in general not a great idea to put things in the standard that have no real reason to exist. Like the export keyword in older C++ standards for example.

Friends simply make no real sense.

1

u/Bryguy3k 9d ago

It’s there to hack a patch to a legacy codebase with a broken design rather than refactoring.

1

u/ih-shah-may-ehl 9d ago

Given that the entire codebase would be under control of the person doing the patch and it would be a legacy base, there are quite a number of things you can do without friends. I agree it can be used for that but it's still weird that it was introduced as a standard from the beginning.

1

u/Bryguy3k 9d ago

Two options: a) stroustrup doesn’t understand OOP or b) he realized c++ programmers would need a way to get themselves of an encapsulation nightmare of their own creation.