Xref: utzoo comp.object:495 comp.lang.c++:5655 Path: utzoo!attcan!uunet!cs.utexas.edu!rice!uw-beaver!uw-june!ewan From: ewan@cs.washington.edu (Ewan Tempero) Newsgroups: comp.object,comp.lang.c++ Subject: Re: Dumb question Message-ID: <9938@june.cs.washington.edu> Date: 26 Nov 89 21:47:23 GMT References: <61737@aerospace.AERO.ORG> Reply-To: ewan@june.cs.washington.edu (Ewan Tempero) Organization: University of Washington, Computer Science, Seattle Lines: 21 In article <61737@aerospace.AERO.ORG> abbott@itro3.org (Russell J. Abbott) writes: >More concretely, can one write a sort routine that will sort a list of >any type (perhaps not yet even defined) that responds to "<"? I would >assume that one could, but it wasn't clear to me from the C++ material >that I have how to do it. You don't. If you want to sort a list, you don't apply a "sort" operation to the list, you ask the list to sort itself. Since the list is an object (we are talking about object-oriented systems where everything is an object, right?) it should know its own representation (including the type of the objects in the list) and so its "sort" operation will know what to do. If it doesn't have a "sort" operation then how can you possibly sort it? If you want to pass it to a "sorting" routine then you are not following the object-oriented paradigm. In general, many so-called "polymorphic" functions don't exist in OO systems. Either the object concerned knows how to perform that function (and so knows its own representation) or it doesn't. If it doesn't, then the problem is in the design of the application. [note: my comments have been stated as fact however they are, of course, my own opinions] --ewan