Hi
I'm currently using business objects which all inherit a common base class.
i.e. Person, and Department, both inherit from Entity.
To not clutter the code, I want to put "== operator" and "Equals" methods in the base class, calling a method "Compare" on the derived class if all else fails.
The reasoning behind this is there are many comparisons which can occur at entity level, which can fast-track the comparison process. However if they fail, it would be nice to have a little method on each subclass which just does some final checks to make the decision.
I've tried to do this, but as "operator ==" is static, it can't call a virtual method. I don't want to implement the workaround where you create a shared instance for the static methods to reference.
Is what I want possible, if not, what's the best way to do this?
I'm currently using business objects which all inherit a common base class.
i.e. Person, and Department, both inherit from Entity.
To not clutter the code, I want to put "== operator" and "Equals" methods in the base class, calling a method "Compare" on the derived class if all else fails.
The reasoning behind this is there are many comparisons which can occur at entity level, which can fast-track the comparison process. However if they fail, it would be nice to have a little method on each subclass which just does some final checks to make the decision.
I've tried to do this, but as "operator ==" is static, it can't call a virtual method. I don't want to implement the workaround where you create a shared instance for the static methods to reference.
Is what I want possible, if not, what's the best way to do this?