Directly it's not possible but you might put those variables which you don't want friend function to access in separate base classes holding that variable. Not sure on this. Maybe someone will correct/refine this.