Path: utzoo!utgpu!news-server.csri.toronto.edu!mailrus!tut.cis.ohio-state.edu!cs.utexas.edu!samsung!uakari.primate.wisc.edu!sdd.hp.com!hp-pcd!hpvcfs1!ericr From: ericr@hpvcfs1.HP.COM (Eric Ross) Newsgroups: comp.lang.c++ Subject: Re: Detecting the first object? Message-ID: <1120007@hpvcfs1.HP.COM> Date: 21 Aug 90 14:37:46 GMT References: <1120006@hpvcfs1.HP.COM> Organization: Hewlett Packard, Vancouver, WA Lines: 37 I received several responses (next day; talk about results!!). Here is one that appears to be in agreement with most of them. Thanks to all that responded. Eric Ross ------------------------------------------ In MyObj.h, say class MyObj { private: static int numObjs; ... public: MyObj(); ... } In MyObj.cc, say #include "MyObj.h" int MyObj::numObjs = 0; MyObj::MyObj() { if (numObjs == 0) { // I am the first object ... } else { // I am not the first } numObjs++; } -- Joe Buck jbuck@galileo.berkeley.edu {uunet,ucbvax}!galileo.berkeley.edu!jbuck