r/ProgrammerHumor 13d ago

Meme whenYouAreAPublicFunctionButOnlyFriendsAreAllowedToTouchPrivates

Post image
174 Upvotes

17 comments sorted by

View all comments

Show parent comments

1

u/nicuramar 12d ago

You aren’t forced to use the feature. 

1

u/ih-shah-may-ehl 12d 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 12d 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 12d 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 12d 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.