Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!think.com!spool.mu.edu!mips!swrinde!elroy.jpl.nasa.gov!ames!haven.umd.edu!uvaarpa!murdoch!astsun7.astro.Virginia.EDU!gl8f From: gl8f@astsun7.astro.Virginia.EDU (Greg Lindahl) Newsgroups: comp.lang.c++ Subject: a beginner's question about container classes Message-ID: <1991Jun1.030004.10159@murdoch.acc.Virginia.EDU> Date: 1 Jun 91 03:00:04 GMT Article-I.D.: murdoch.1991Jun1.030004.10159 Sender: usenet@murdoch.acc.Virginia.EDU Organization: Department of Astronomy, University of Virginia Lines: 18 I would like to implement a set of small and beautiful container classes like SmallTalk. Yes, I know that NIH exists. I only let things derived from class ContainedObject to be within a container class. I don't want all my objects to be a huge tree, just the things that go in containers. Anyway, that's not what I'm asking. When you're searching through a container, you need an equivalence function. If I'm comparing a ContainedInt to a ContainedKitchenSink, I'd like it to always be unequal. If I compare a ContainedInt to a ContainedInt, I'd like a method in ContainedInt to be called. What's the best way to do this? Can I directly get at something that tells me what class an object is, or do I need to kludge it and create a private member that's always at the same offset and test that? I should mention that my only reference is the awful book "An Intro to O-O Programming and C++". I should get a better reference :-/