delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1999/10/02/14:57:53

From: Weiqi Gao <weiqigao AT a DOT crl DOT com>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: no copy-ctor for temps
Date: Sat, 02 Oct 1999 13:40:17 -0500
Organization: CRL Network Services
Lines: 33
Message-ID: <37F65191.DE3DF578@a.crl.com>
References: <37F562D4 DOT 57291365 AT a DOT crl DOT com> <eb8J3.1214$%K6 DOT 36 AT firefly> <pafJ3.1246$%K6 DOT 47 AT firefly>
NNTP-Posting-Host: a116011.stl1.as.crl.com
Mime-Version: 1.0
X-Mailer: Mozilla 4.51 [en] (X11; I; Linux 2.2.5-15 i586)
X-Accept-Language: en
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

"Wendy E. McCaughrin" wrote:
> 
>  2 questions:
> 
>  1. Your reference for the above assertion?

[1] Bjarne Stroustrup, The C++ Programming Language, 3rd. ed.,
Addison-Wesley, Reading, MA, 1997, p. 145, ll.(-12)--(-11).

>  2. You say that the new object is merely constructed at the place
>     where temp is allocated -- how is this different from bit-wise
>     copy? By "construct" do you mean the char* ctor is invoked to
>     build 'temp' -- then I agree it is not bit-wise copy. But you
>     express it like assignment, which defaults to bit-wise copy.

I goofed on the second temp.  I should have written:

  TstCpy(Overflow(" I an a temporary\n"));

is akin to

  Overflow temp(" I an a temporary\n");

which does not invoke the copy constructor, but invokes the constructor
to construct temp directly on the stack of TstCpy().

BTW.  You can see the constructor being called by either inserting a
debugging "cout <<" inside the constructor, or by stepping through the
code with gdb.

-- 
Weiqi Gao
weiqigao AT a DOT crl DOT com

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019