🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.std.c++
Article #2190

Re: Q: is A a = 100; equivalent to A a (100); ?

#2190
From: Anthony S. H. Lee
Date: Sat, 14 Oct 1995 09:36
39 lines
1979 bytes
Jean-Louis Moser (jlm@two-oo-one.fr) wrote:
: | According to the standard, are the two lines of the main
: | equivalent ? My Opinion is yes, but one of my compilers would
: | like to access copy contructor to be happy with the
: | second line as if it would like to build a2 from a temporary A
: | which would be build from the int value 99. If we make copy
: | constructor public, this one isn't called, but the compiler
: | is happy. Thank you for answers.

: #include <iostream.h>

: class A {
: public:
:     A (int i) {cout << "A" << endl;}
: private:
:     A (const A&) {cout << "COPY" << endl;}
: };

: void main ()
: {
:     A a1 (100);
:     A a2 = 99;
: }

Have you tried to remove the copy constuctor?
You are right! S. Lippman described this characteristic in his
book, 'C++ Primer'

Your compiler may not following the C++ standard!
Can you tell us what brand it was? :)

--
! Anthony S. H. Lee [Lee, Shih Hao]         Internet: tony@ews360.nec.com.tw
! BIG5:'uh;( EUC:JWDIk0     MSN: Anthony_S_H_Lee     Anthony_S_H_Lee@MSN.com
! Lee-fruit, Shih-scholar, Hao-hero        WWW http://necta.nec.com.tw/~tony
---
[ comp.std.c++ is moderated.  Submission address: std-c++@ncar.ucar.edu.
  Contact address: std-c++-request@ncar.ucar.edu.  The moderation policy
  is summarized in http://dogbert.lbl.gov/~matt/std-c++/policy.html. ]
Technical Details
Message-ID: <45l4m8$qtu@aladdin.iii.org.tw>
Path: arc1-ca.pugleaf.net!in1.uu.net!bounce-back
References: <JLM.95Oct12202250@ludo.two-oo-one.fr>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!in1.uu.net!bounce-back
Date: 14 Oct 95 09:36:41 GMT
Approved: fjh@cs.mu.oz.au
From: tony@ews360.nec.com.tw (Anthony S. H. Lee)
Newsgroups: comp.std.c++
Subject: Re: Q: is A a = 100; equivalent to A a (100); ?
X-Original-Date: 13 Oct 1995 07:32:24 GMT
Organization: Institute for Information Industry
Message-ID: <45l4m8$qtu@aladdin.iii.org.tw>
References: <JLM.95Oct12202250@ludo.two-oo-one.fr>
X-Newsreader: TIN [version 1.2 PL2]
X-Auth: PGPMoose V1.1 PGP comp.std.c++
 iQBFAgUBMH+ExuEDnX0m9pzZAQGudgGAlpPT+Um9GdjUSKt1GUi1uz+Dy7+CbA/v
 nonZ6yRlC/CVu18Ul47ITP7Idl9Bvs7M
 =SH9P