delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/06/16/04:28:35

Message-ID: <c=GB%a=_%p=Indigo_Active_Vi%l=CRIANLARICH-970616083252Z-256@crianlarich.Indigo>
From: Robert Humphris <r DOT humphris AT indigo-avs DOT com>
To: "'djgpp AT delorie DOT com'" <djgpp AT delorie DOT com>,
"'Roberto Henriquez Laurent'"
<shl24634 AT alumnos DOT inf-cr DOT uclm DOT es>,
"'Bryan Murphy'"
<bryan DOT murphy AT hcst DOT com>
Subject: RE: copy constructor
Date: Mon, 16 Jun 1997 09:32:52 +0100
Encoding: 23 TEXT

>
>>----------
>>>          bozo = new CLOWN("anak");
>>
>>  I think that's wrong (to assign an object variable a pointer value),
>>i.e., for that sentence to work, bozo should be CLOWN*, not CLOWN. So
>>maybe it should be
>>
>>    bozo = CLOWN("anak");     //Would this work?
>>
No, as you are using a copy constructor which has not been overloaded...
what you need is to use the operator function in your class descriptor
thus:

void CLOWN::operator=( CLOWN &obj )
{
	// copy each basic type over e.g.
	nFeetSize = obj.nFeetSize;
}

Rob
>

- Raw text -


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