🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: gnu.g++.help
Article #69

Re: implicit member-wise assignment

#69
From: Don &
Date: Fri, 17 Apr 1992 06:44
50 lines
1664 bytes
>>>>> On 9 Apr 92 05:46:54 GMT, glipton@ajax.intel.com (Gary Lipton) said:

Gary> That is, if I have a class "Foo", then the code

Gary>    Foo foo1, foo2;

Gary>    foo1 = foo2;

Gary> is legal, and will copy the members of foo1 into foo2, without
Gary> an explicit declaration of "=".

Gary> But I find that using g++, I would need the statement

Gary>   Foo operator=(Foo);

Gary> in my Class declaration for this code to compile.

That's funny.  I'm using gcc-2.1 on a Sparc running SunOS4.1.1
and implicit assignment works fine for me.  The code appended
to this message comiles fine with the command "g++ assig.cc"

By the way, the usual assingment operator is

  Foo& operator=(const Foo&);

Don Bashford
bashford@scripps.edu

--------------------------assig.cc------------------------------
class Pub {
public:
  int x, y;
  Pub(int xc, int yc) {x = xc; y=yc;}
};

class Priv {
private:
  int x, y;
public:
  Priv(int xc, int yc) {x = xc; y=yc;}
};

main() {
  Pub pub1(2,3);
  Pub pub2(4,5);
  pub2 = pub1;
  Priv priv1(5,6);
  Priv priv2(7,8);
  priv2 = priv1;
}
Technical Details
Message-ID: <BASHFORD.92Apr16234459@zerbina.scripps.edu>
Path: arc1-ca.pugleaf.net!sparky!uunet!think.com!rpi!uwm.edu!ogicse!network.ucsd.edu!scripps!riscsm!bashford
References: <10299@inews.intel.com>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!sparky!uunet!think.com!rpi!uwm.edu!ogicse!network.ucsd.edu!scripps!riscsm!bashford
From: bashford@scripps.edu (Don &)
Newsgroups: gnu.g++.help
Subject: Re: implicit member-wise assignment
Message-ID: <BASHFORD.92Apr16234459@zerbina.scripps.edu>
Date: 17 Apr 92 06:44:59 GMT
Article-I.D.: zerbina.BASHFORD.92Apr16234459
References: <10299@inews.intel.com>
Sender: news@Scripps.EDU
Organization: Scripps Research Institute, La Jolla, CA, USA
Lines: 50
In-reply-to: glipton@ajax.intel.com's message of 9 Apr 92 05:46:54 GMT