Topic: memberwise copy and/or initialization of array members
Author: jimad@microsoft.UUCP (Jim ADCOCK)
Date: 8 Aug 91 20:27:17 GMT Raw View
Given a class with an array member:
class A
{
public:
double ar[100];
};
r12.8 states that [regards assignment operator and copy constructor]
"If not defined by the programmer, they will be defined as memberwise
assignment and memberwise initialization of the members of X respectively."
Since ar is the member, and initialization or assignment of arrays
is illegal, the memberwise initialization or assignment must be
illegal, and the default assignment operator or copy constructor
cannot be generated.
Yes, No, Maybe?
-- Please defend your opinion based on statements found in the language
reference, and in particular in light of the rules for assignment and
initialization of arrays. [IE I already know what compiler XYZ does
in this situation. I just want to know *based on the reference* how
these actions are justified. Or better yet, I'd like to see arrays
get "fixed"]
Author: jbuck@forney.berkeley.edu (Joe Buck)
Date: 13 Aug 91 18:08:06 GMT Raw View
In article <74093@microsoft.UUCP>, jimad@microsoft.UUCP (Jim ADCOCK) writes:
[ First off, Jim, ask your system administrator to fix your "rn" to
insert your correct address, which is microsoft.com. Those of us
with no UUCP connections must manually rewrite host.uucp addresses
when we reply. Thanks. ]
|> Given a class with an array member:
|>
|> class A
|> {
|> public:
|> double ar[100];
|> };
|>
|> r12.8 states that [regards assignment operator and copy constructor]
|> "If not defined by the programmer, they will be defined as memberwise
|> assignment and memberwise initialization of the members of X respectively."
|>
|> Since ar is the member, and initialization or assignment of arrays
|> is illegal, the memberwise initialization or assignment must be
|> illegal, and the default assignment operator or copy constructor
|> cannot be generated.
|>
|> Yes, No, Maybe?
We discussed this same point about six months ago. Stroustrup said his
attention was for the "right thing" to happen (copy each element of the
array). This means that the ARM description of the default copy constructor
must be amended.
--
Joe Buck
jbuck@galileo.berkeley.edu {uunet,ucbvax}!galileo.berkeley.edu!jbuck