Because both string members are members to reference you have to construct
using a reference.
If the members where of type String istead of String& you had a choice, but
in that case I also should prefer passing a reference, not because of the
size of the string, but because when passing an object, it must be
constructed and initialized, with takes more time.
> -----Original Message-----
> From: Daniel Glenfield [mailto:sp...@ho...]
> Sent: Friday, January 10, 2003 10:19 AM
> To: dev...@li...
> Subject: [Dev-C++] Passing by value or reference to constructor
> initialiation list
>
>
>
>
> I would like to know whether it is better to pass the
> following string
> objects and integer by value or reference to my constructor
> initialisation
> list.
>
> Vehicle::Vehicle
> (
> String& VehicleName,
> String& VehicleType,
> int SerialNumber
> ):
> mVehicleName(VehicleName),
> mVehicleType(VehicleType),
> mSerialNumber(SerialNumber)
> {
> }
>
> an integer is only 4 bytes I think, so by value would be
> fine, but what
> about the string objects? Can I pass by reference?
>
>
> _________________________________________________________________
> Protect your PC - get McAfee.com VirusScan Online
> http://clinic.mcafee.com/clinic/ibuy/campaign.asp?cid=3963
>
>
>
> -------------------------------------------------------
> This SF.NET email is sponsored by:
> SourceForge Enterprise Edition + IBM + LinuxWorld = Something 2 See!
> http://www.vasoftware.com
> _______________________________________________
> Dev-cpp-users mailing list
> Dev...@li...
> TO UNSUBSCRIBE: http://www.noicys.cjb.net/devcpp/ub.htm
> https://lists.sourceforge.net/lists/listinfo/dev-cpp-users
>
|