If you want to avoid the construction and destruction of temporary object=
s
(the function arguments) then pass by reference. Usually for non-built in
types we pass by reference.=0D
=0D
=0D
Ioannis Vranos=0D
=0D
* Programming pages: http://www.noicys.freeurl.com=0D
* Alternative URL: http://run.to/noicys =0D
=0D
=0D
-------Original Message-------=0D
=0D
From: Daniel Glenfield=0D
Date: =D0=E1=F1=E1=F3=EA=E5=F5=DE, 10 =C9=E1=ED=EF=F5=DC=F1=E9=EF=F2 2003=
12:05:21 =EC=EC=0D
To: ner...@my...; dev...@li...=0D
Subject: Re: [Dev-C++] Passing by value or reference to
constructorinitialiation list=0D
=0D
Well I think passing by reference is better because the objects could be =
=0D
large, which means more on the stack and thus more overhead, but are ther=
e =0D
any side effects to passing by reference to the constructor in this way?=0D
=0D
=0D
>From: Banjo Donila <ner...@my...>=0D
>To: Daniel Glenfield <sp...@ho...>=0D
>Subject: Re: [Dev-C++] Passing by value or reference to =0D
>constructorinitialiation list=0D
>Date: 10 Jan 2003 17:49:28 +0800=0D
>=0D
>it depends on what you want to happen=0D
>=0D
>On Fri, 2003-01-10 at 17:19, Daniel Glenfield wrote:=0D
> >=0D
> >=0D
> > I would like to know whether it is better to pass the following strin=
g=0D
> > objects and integer by value or reference to my constructor =0D
>initialisation=0D
> > list.=0D
> >=0D
> > Vehicle::Vehicle=0D
> > (=0D
> > String& VehicleName,=0D
> > String& VehicleType,=0D
> > int SerialNumber=0D
> > ):=0D
> > mVehicleName(VehicleName),=0D
> > mVehicleType(VehicleType),=0D
> > mSerialNumber(SerialNumber)=0D
> > {=0D
> > }=0D
> >=0D
> > an integer is only 4 bytes I think, so by value would be fine, but wh=
at=0D
> > about the string objects? Can I pass by reference?=0D
> >=0D
> >=0D
> > _________________________________________________________________=0D
> > Protect your PC - get McAfee.com VirusScan Online=0D
> > http://clinic.mcafee.com/clinic/ibuy/campaign.asp?cid=3D3963=0D
> >=0D
> >=0D
> >=0D
> > -------------------------------------------------------=0D
> > This SF.NET email is sponsored by:=0D
> > SourceForge Enterprise Edition + IBM + LinuxWorld =3D Something 2 See=
!=0D
> > http://www.vasoftware.com=0D
> > _______________________________________________=0D
> > Dev-cpp-users mailing list=0D
> > Dev...@li...=0D
> > TO UNSUBSCRIBE: http://www.noicys.cjb.net/devcpp/ub.htm=0D
> > https://lists.sourceforge.net/lists/listinfo/dev-cpp-users=0D
> >=0D
=0D
=0D
_________________________________________________________________=0D
Add photos to your e-mail with MSN 8. Get 2 months FREE*. =0D
http://join.msn.com/?page=3Dfeatures/featuredemail=0D
=0D
=0D
=0D
-------------------------------------------------------=0D
This SF.NET email is sponsored by:=0D
SourceForge Enterprise Edition + IBM + LinuxWorld =3D Something 2 See!=0D
http://www.vasoftware.com=0D
_______________________________________________=0D
Dev-cpp-users mailing list=0D
Dev...@li...=0D
TO UNSUBSCRIBE: http://www.noicys.cjb.net/devcpp/ub.htm=0D
https://lists.sourceforge.net/lists/listinfo/dev-cpp-users=20
|