From -2703223423517638133
X-Google-Thread: f78e5,51456c3eb8f9490e
X-Google-Attributes: gidf78e5,public
X-Google-Language: ENGLISH,ASCII-7-bit
Path: g2news2.google.com!news4.google.com!news.glorb.com!peer1.news.newnet.co.uk!194.159.246.34.MISMATCH!peer-uk.news.demon.net!kibo.news.demon.net!news.demon.co.uk!demon!stump.algebra.com!devnull
From: fgothamNO@SPAM.com (Frederick Gotham)
Newsgroups: comp.std.c++
Subject: Re: Copy Constructor Confusion!
Date: Wed, 16 Aug 2006 16:22:38 GMT
Organization: Eircom.Net http://www.eircom.net
Lines: 41
Sender: mail2news@demon.net
Approved: fjh@cs.mu.oz.au (Fergus Henderson , moderator of comp.std.c++)
Message-ID: <URnEg.12707$j7.324710@news.indigo.ie>
References: <1155645873.296811.3890@74g2000cwt.googlegroups.com> <hPkEg.12700$j7.324766@news.indigo.ie> <4kebv5Fbjid9U3@individual.net>
NNTP-Posting-Host: news.news.demon.net
X-Trace: news.demon.co.uk 1155745367 15414 158.152.254.254 (16 Aug 2006 16:22:47 GMT)
X-Complaints-To: abuse@demon.net
NNTP-Posting-Date: Wed, 16 Aug 2006 16:22:47 +0000 (UTC)
X-Original-To: std-c++@mailman.ucar.edu
X-Robomod: STUMP, ichudov@algebra.com (Igor Chudov)
X-User-Agent: Xnews/5.04.25
X-Greylisting: NO DELAY (Relay+Sender autoqualified);
	processed by UCSD_GL-v2.1 on mailbox7.ucsd.edu;
	Tue, 15 August 2006 10:52:54 -0700 (PDT)
X-Virus-Scanned: amavisd-new at csse.unimelb.edu.au
X-Received: (from fjh@localhost)
	by mulga.csse.unimelb.edu.au (8.13.6+Sun/8.13.6/Submit) id k7GGMcIX025753;
	Thu, 17 Aug 2006 02:22:38 +1000 (EST)
X-Path: comp-std-cpp-robomod!not-for-mail
X-NNTP-Posting-Date: Tue, 15 Aug 2006 18:52:52 BST
X-Delivered-To: std-c++@mailman.ucar.edu
X-Spamscanner: mailbox7.ucsd.edu  (v1.6 Jul  6 2006 16:38:12, 0.0/5.0 3.1.3)
X-Authentication-Warning: mulga.csse.unimelb.edu.au: fjh set sender to devnull@stump.algebra.com using -f
X-Newsgroups: comp.std.c++
X-MailScanner: PASSED (v1.2.8 76545 k7FHqrwp082892 mailbox7.ucsd.edu)
Xref: g2news2.google.com comp.std.c++:3290

"Matthias Hofmann" posted:

>> template<class T>
>> void Func()
>> {
>>    T arr[1] = {};
>>
>>    T &obj = *arr;
>>
>>    /* Now work with "obj" */
>> }
> 
> This looks rather strange. How does it exactly work? What's the deal with 
> those curly brackets?


Here's how you default-initialise every element of an array:

    int array[5] = {};

This works with every type. I use it with an array of length 1:

    int array[1] = {};

, so the sole element gets default-initialised. I then create a reference 
to the first element:

    int array[1] = {};

    int &i = *array;

-- 

Frederick Gotham

---
[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://www.comeaucomputing.com/csc/faq.html                      ]



