🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

implicit member-wise assignment

#48
From: John D. Sutter
Date: Fri, 10 Apr 1992 04:05
27 lines
1032 bytes
 [ posted for a friend -- jds ]

I am just learning C++.  My references tell me that "=" is
implicitly defined as member-wise assignment between operands
of a given class.

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

   Foo foo1, foo2;

   foo1 = foo2;

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

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

  Foo operator=(Foo);

in my Class declaration for this code to compile.

Is there a way to get g++ to provide implicit assignment?  Or
am I on the wrong track entirely?

Please send replies to glipton@sedona.intel.com; our news access
has been shut down recently.  Thanks.
Technical Details
Message-ID: <6723@m2c.m2c.org>
Path: arc1-ca.pugleaf.net!sparky!uunet!cs.utexas.edu!qt.cs.utexas.edu!news.Brown.EDU!noc.near.net!nic.umass.edu!m2c!jds

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!sparky!uunet!cs.utexas.edu!qt.cs.utexas.edu!news.Brown.EDU!noc.near.net!nic.umass.edu!m2c!jds
From: jds@m2c.org (John D. Sutter)
Newsgroups: gnu.g++.help
Subject: implicit member-wise assignment
Message-ID: <6723@m2c.m2c.org>
Date: 10 Apr 92 04:05:31 GMT
Organization: Intel Corp, Chandler, AZ
Lines: 27