CompuServe Messages

#C++ &-Referencing

    02-Mar-90 23:18:08
Fm: Greg Comeau@Comeau Cmptg 72331,3421
To: Bob Goldrich 73427,2414
Good question. It's one that blows a lot of people's minds for a long time and also a statement that seems so nonchalant radiating from those saying it that you're convinced it's just hype. At the lowest level, a library is a library, and that's the end of that. The gist of the difference is that in OOP/C++/etc a few additional things occur. First data and functions (or the operations that can be performed on and returned from the data) can be encapsulated and therefore modularized instead of what I call "random functions and random data working together by accident". In other words, a method to the madness can be presented and furthermore in can occur in a more natural way. Once this is done, certain side-effects can happen that make it better feasible than a mere function sitting naked in a library. The thing is that in general a function library, although very nice, is a collection of routines each promising to do say one thing good (which is good of course). However, what do you do if you want that routines to do something almost like the way you did it the last but, but with this deletion or that addition? Your only choice is to rewrite is from scratch. But then that means you've got to give it a name, perhaps a "funny" one since it might do the same thing as the original one, with with a slight twist. With the modular approach mentioned above, that need not be the case and it can be representitive of a building/deletion block. You just can't do this with a library. Also, let's say we've got a sort routine. What you want to do is to be able to say in your code: sort(something). You don't want to be concerned necessarily about the types of the things you want sorted. In C, something like qsort() might solve this in part, but what it you've got maybe structures with 'char *' pointers or something as its elements that you want sorted? Where do you go from there? (Continues)