compare private members of two class instances

A

Avi

Hi all,

I have two instances of the same class. Is it possible to compare private
members of two classes and to come with a list of differences?

Thanks,
Avi
 
F

Family Tree Mike

Not from outside of the class. You should make a public method on the class
which takes an instance of the class, and compares it to the instance. The
ICompare interface is used for sorting, among other things, and is an example
of this mechanism.
 
B

Ben Voigt [C++ MVP]

Family Tree Mike said:
Not from outside of the class. You should make a public method on the
class
which takes an instance of the class, and compares it to the instance.
The
ICompare interface is used for sorting, among other things, and is an
example
of this mechanism.

Alternatively reflection can let you read private members of any object *if*
you have the security privileges to do so.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top