Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!sun-barr!ccut!kogwy!new1!roger From: roger@zuken.co.jp (Roger Meunier) Newsgroups: comp.lang.c++ Subject: Re: Whats wrong with this picture (or am I slow?) Message-ID: Date: 11 Oct 90 19:10:59 GMT References: <90281.014850EACONS@MTUS5.BITNET> Sender: news@new1.zuken.co.jp Organization: ZUKEN Inc. Yokohama, JAPAN Lines: 23 In-reply-to: EACONS@MTUS5.BITNET's message of 8 Oct 90 06:48:50 GMT In article <90281.014850EACONS@MTUS5.BITNET> EACONS@MTUS5.BITNET (Ernie Anderson) writes: > String a; > ... > a = String (buffer); > > Now when a was declared, a single character of storage was allocated, right? > and when buffer was converted to a String and assigned to a, the value of > str in that temporary instance for buffer was copied to a's str, right? So > isn't the byte of storage allocated by declaring a lost? I don't have a copy of the book which contains the example, but I would assume that within the portion of the class declaration of String which you abreviated, the equals (=) operator has been redefined. I would also assume that said redefinition included the deletion of the old string contents and then a copying of the pointer given as the rhs of the operator to the lhs instance. In the above example, the rhs is probably an implicitly defined (auto) instance of String which contains a pointer to a copy of buffer. Just a guess... -- Roger Meunier @ Zuken, Inc. Yokohama, Japan (roger@zuken.co.jp)