Path: utzoo!mnetor!uunet!husc6!cmcl2!rutgers!bellcore!faline!ulysses!sfmag!sfsup!grk From: grk@sfsup.UUCP (G.R.Kuntz) Newsgroups: comp.lang.c++ Subject: dynamic vs. static binding Message-ID: <2658@sfsup.UUCP> Date: 22 Jan 88 14:53:49 GMT Organization: AT&T-IS, Summit N.J. USA Lines: 55 I've recently been reading Brad Cox's book "Object Oriented Programming" and some of the examples that he gives are causing me a dilemma. Let's say we have a dynamically bound OO language and we want to write the following program (syntax is C++/SMALLTALK/kludge): class container { // ... public: message("add:"); message("weight"); }; class pen { // ... public: message("weight"); }; class pencil { // ... public: message("weight"); }; class eraser { // ... public: message("weight"); }; container pencilBox; pen pen1, pen2, pen3; pencil pencil1, pencil2; eraser eraser1, eraser2, eraser3; pencilBox.add(pen1); pencilBox.add(pen2); pencilBox.add(pen3); pencilBox.add(pencil1); pencilBox.add(pencil2); pencilBox.add(eraser1); pencilBox.add(eraser2); pencilBox.add(eraser3); cout << pencilBox.weight(); My question: is there any general way of writing the container class in a statically bound language without writing a ``container_thingie'' class and having all objects that may potentially be put in a container be derived from container_thingie? P.S. cat flames > /dev/null -- G. Ralph Kuntz N2HBN grk@attunix.att.com N2HBN @ KB1BD-4