Passing function to a class
843793May 19 2002 — edited Jul 15 2002Hi !
Due to the genericity, it's possible to be in the situation of the incapacity to compare 2 objects of a user define type because the comparision field may be a special attribute in the object "type". So, is it possible to pass a compare function to a class to do the comparision ?!
Example :
In a BinaryTree class, I want to store object containing these attributes : ReferenceNumber, Name, Price. The insertion criteria in the binary tree is on the ReferenceNumber attribute. In the generic BinaryTree class, I will not know that this attribute exist because it's generic... so I want to pass to the class the functions "Equal", "LessThan" and "GreaterThan" who will compare the user define type, in the generic class.
Can I do it and if so, How can I do it ?!
Thanks !!
Pascal ;