From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 3314 invoked by alias); 6 Mar 2007 12:46:41 -0000 Received: (qmail 3304 invoked by uid 22791); 6 Mar 2007 12:46:40 -0000 X-Spam-Check-By: sourceware.org Received: from exprod6og56.obsmtp.com (HELO exprod6og56.obsmtp.com) (64.18.1.208) by sourceware.org (qpsmtpd/0.31) with SMTP; Tue, 06 Mar 2007 12:46:35 +0000 Received: from source ([192.150.11.134]) by exprod6ob56.postini.com ([64.18.5.12]) with SMTP; Tue, 06 Mar 2007 04:46:33 PST Received: from inner-relay-1.corp.adobe.com ([153.32.1.51]) by outbound-smtp-1.corp.adobe.com (8.12.10/8.12.10) with ESMTP id l26CkJD1013169; Tue, 6 Mar 2007 04:46:19 -0800 (PST) Received: from fe2.corp.adobe.com (fe2.corp.adobe.com [10.8.192.72]) by inner-relay-1.corp.adobe.com (8.12.10/8.12.10) with ESMTP id l26CkXI9003316; Tue, 6 Mar 2007 04:46:33 -0800 (PST) Received: from namailgen.corp.adobe.com ([10.8.192.91]) by fe2.corp.adobe.com with Microsoft SMTPSVC(6.0.3790.1830); Tue, 6 Mar 2007 04:46:32 -0800 Received: from 10.32.16.88 ([10.32.16.88]) by namailgen.corp.adobe.com ([10.8.192.91]) via Exchange Front-End Server namailhost.corp.adobe.com ([10.8.192.70]) with Microsoft Exchange Server HTTP-DAV ; Tue, 6 Mar 2007 12:46:32 +0000 User-Agent: Microsoft-Entourage/11.3.3.061214 Date: Tue, 06 Mar 2007 14:58:00 -0000 Subject: Re: G++ and constructors From: John Love-Jensen To: Sean MacLennan , MSX to GCC Message-ID: In-Reply-To: Mime-version: 1.0 Content-type: text/plain; charset="US-ASCII" Content-transfer-encoding: 7bit X-IsSubscribed: yes Mailing-List: contact gcc-help-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-help-owner@gcc.gnu.org X-SW-Source: 2007-03/txt/msg00077.txt.bz2 Note: I put in the init_instance() presuming you wanted to do some extra work in there -- such as whatever lock() and unlock() are doing. If you don't need to do any extra work, then you can collapse it to the simpler: ---------------------------------------------------------------------- myclass* myclass::get_instance() // public: static { static myclass* instance = new myclass; return instance; } ---------------------------------------------------------------------- Sorry if I previous more complicated example caused confusion. --Eljay