How to override Buddypress core files?

Hi there. I'm trying to figure out how to override Buddypress core files correctly. I would like to tweak a file called class-bp-core-members-widget.php that is in /plugins/buddypress/bp-members/classes/ but in a safe way that won't be erased if Buddypress were to update. I know that with buddypress templates, you follow the template hierarchy in the child theme and copy the files, etc, but doing the same with the core files doesn't work.

I tried to do googling but nothing was really clear enough on how to approach this. Any help? Thanks in advance!