In reply to dave_59:
Thanks Dave. so what if I do not know about the type of object and hence I also do not know about what are the fields in the class. In the example above you have called compare methods for each field. All I want is to compare each of that class and mismatch an error which says this is the field has mismatch with lhs and rhs having different value.
Adding to the point. Yes I am using UVM and I have used uvm_algorithmic_comparator where we pass before_tx, after_tx, and transformer type. I have implemented the transformer function which returns the after_tx. I want to know how does it print particular field when there is a mismatch. For example if after_tx has a field called data then how does comparator knows about the data field since we have passed only object. because mostly we compare whole objects.