From kscott@silicon.csci.csusb.edu Tue Oct 3 18:23 PDT 1995 From: "Katherine A. Scott" <kscott@orion.csci.csusb.edu> To: "Dr. Richard Botting" <dick@blaze.csci.csusb.edu> Subject: Re: New program > > > Mod5 operator+(Mod5 a, Mod5 b){ return Mod5( (a.v + b.v)%5 ); } Mod5(int i){ v = i % 5; } Yes, it does compile and actually works for what I wanted it to. (Amazing enough, eh?) While you were talking about operator overloading, I started thinking about all of the wonderful applications this would have on abstract algebra. I started writing a program based on the very simple group < Zsub5, addition mod 5 >. If I enter two integers (a and b), the computer will use the group operations to find the group element a*b. I had planned to write this using operator overload, but found that it was more efficient not to. I plan to expand the program later for larger, more difficult groups (for example, the set of all rotations and reflections on a figure....) It would be nice to have a program that would find all of the elements of a particular group. Or a program that would be able to add the members of two groups (finally using operation overload!) ++ I have written a brief summary of Group theory and what the program does. If you want to, you can skip this stuff. As a reminder, a group is a non-empty set G and a binary operation (usually multiplication or addition) that satisfies three properties. 1) If a and b are elements of G, then a*b (where * is the group operation) is also in G. (It is easy to see that division and subtraction would not work in most cases.) 2) There is an identity e in G such that for all a in G, a*e = e*a = a. 3) For all a in G, there exists some element b such that a*b = b*a = e. (Not that each element can have a different inverse.) In this case, my non-empty set G is Zsub5, or {0,1,2,3,4}. (The first five positive integers) The binary operation is addition mod five. (You can take a few elements and see that the properties of Group are satisfied.) So, if I enter a = 7 and b = 5, I get ( 7+5 mod 5 ) = 12 mod 5 = 2 so 7*5 = 2. It might be interesting to note that 7 is equivalent to 2 mod 5, and 5 = 0 mod 5. 2*0 = 2. Yours, Katherine