Path: utzoo!attcan!uunet!ogicse!husc6!ngo From: ngo@tammy.harvard.edu (Tom Ngo) Newsgroups: comp.lang.c++ Subject: Tricky (I think) question about inheritance Message-ID: Date: 25 Sep 90 18:56:02 GMT Sender: news@husc6.harvard.edu Distribution: comp Organization: Harvard Chemistry Department Lines: 37 I would appreciate any advice about the following situation. I have three classes, which for anonymity's sake I will call B, B1 and B2: class B { ... }; class B1 : private B { ... }; class B2 : private B { ... }; and I have another class, Collector, with a method that memorizes B's: Collector::memorize( B *p ) { ... } I want the method memorize() to maintain a linked list (or whatever) consisting of all the B's with which memorize() has been invoked. I want the Collector class to contain complete copies of those B's, i.e. I want the elements of this list to survive even after the following sequence: Collector c; B1 *b1 = new B1(...); c.memorize(b1); delete b1; This means that inside Collector::memorize() I must invoke "new B"... but that is obviously not going to be enough, since a B cannot hold all of the information in, say, a B1. Are there any suggestions on how to handle this? Please respond via email; I will summarize. Thanks in advance. -- Tom Ngo ngo@harvard.harvard.edu 617/495-1768 lab number, leave message