Path: utzoo!attcan!utgpu!jarvis.csri.toronto.edu!mailrus!uwm.edu!uakari.primate.wisc.edu!gem.mps.ohio-state.edu!apple!well!nagle From: nagle@well.UUCP (John Nagle) Newsgroups: comp.lang.c++ Subject: Re: Allowing only one instantiation of a class Message-ID: <14092@well.UUCP> Date: 13 Oct 89 17:13:49 GMT References: <672@suntops.Tops.Sun.COM> Reply-To: nagle@well.UUCP (John Nagle) Organization: Whole Earth 'Lectronic Link, Sausalito, CA Lines: 19 In article <672@suntops.Tops.Sun.COM> rdas@hatter.Tops.Sun.COM (Robin Das) writes: > >How do you allow only one instantation of a class across a system? Well, you could write class onceonly { static unsigned char instances = 0; ... onceonly() { assert(instances==0); instances++; } }; which ought to get the idea across. There's no way to express the idea in a way that the compiler will enforce it. John Nagle