.TH G_EQUAL 2 "8 April 1991" "Demeter" "Demeter Software" .SH NAME g_equal \- send the generic equal message to an object. .SH SYNOPSIS virtual int Universal:: .I g_equal ( Universal* otherObject ) .SH DESCRIPTION .I g_equal performs a deep comparison for equality between the object to which the message is sent and an argument object. This means that .I g_equal succeeds only if both objects are of the same type, they have the same instantiated parts and each part succeeds when sent g_equal with the corresponding part of the argument object. The receiving and the argument objects must be a tree objects. That is, they cannot have any cycles or shared subobjects. .SH REDEFINITION Since .I g_equal is a virtual function, it can be redefined at any user class. This means that the user can modify the criterion by which any object of some particular class is equal to any other object. As a technical consideration, making g_equal virtual allows to define it recursively and to give the termination condition as a redefinition at the terminal classes DemIdent, DemNumber, DemReal, DemString, and DemText. .SH RETURN VALUES .I g_equal returns an integer 1 if it succeeds and an integer 0 otherwise. For example: Compound* iComp1 = new Compound(); .br Compound* iComp2 = new Compound(); .br Compound* iComp3; .br Compound* iComp4 = new Compound(); iComp1 = (Compound*)iComp1->g_parse("input1"); .br iComp2 = (Compound*)iComp2->g_parse("input2"); .br iComp3 = (Compound*)iComp1->g_copy(); .br iComp4 = (Compound*)iComp2->g_parse("input2"); int a = iComp1->g_equal( iComp2 ); // returns 0, false .br int b = iComp1->g_equal( iComp3 ); // returns 1 .br int c = iComp2->g_equal( iComp4 ); // returns 1 .br int d = iComp3->g_equal( iComp4 ); // returns 0 .SH SEE ALSO g_parse(2), g_copy(2), terminal(2) .SH REFERENCES .I User Manual for The C++ Demeter System .br Walter L. Hursch .br Northeastern University, 1993 .I The Annotated C++ Reference Manual .br Margaret A. Ellis and Bjarne Stroustrup .br Addison-Wesley, 1990 .I C++ Primer .br Stanley B. Lippman .br Addison-Wesley, 1989