Is there a way to write an equality test for a VBA class with private members without exposing knowledge of the existence of those private members?
I would write the class like this
Private mdhidden1_ As Double
Private mdhidden2_ As Double
Public Property Get hidden1_() As Double
hidden1_ = mdhidden1_
End Property
Public Property Get hidden2_() As Double
hidden2_ = mdhidden2_
End Property
Private Sub Class_Initialize()
'some method of setting variables private to the class
mdhidden1_ = 1
mdhidden2_ = 2
End Sub
Public Property Get IsEquivalent(clsCompare As C) As Boolean
IsEquivalent = Me.hidden1_ = clsCompare.hidden1_ And Me.hidden2_ = clsCompare.hidden2_
End Property
If you're forced to expose knowledge of the member anyway, you may as well make it a read-only property (Get, but no Let). Then you can make the IsEquivalent boolean property inside the class.