home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.c++
- Path: sparky!uunet!titan!lpi!pkt
- From: pkt@lpi.liant.com (Scott Turner)
- Subject: Re: const on pass by value
- Message-ID: <1992Jul27.174500.296@lpi.liant.com>
- Sender: pkt@lpi (Scott Turner)
- Organization: Liant Software Corporation
- References: <1992Jul24.151010.11969@PacBell.COM> <1992Jul24.172325.25348@watson.ibm.com>
- Date: Mon, 27 Jul 1992 17:45:00 GMT
- Lines: 25
-
- mittle@watson.ibm.com (Josh Mittleman) writes:
- |> pjcondi@lepton (Paul Condie) writes:
- |>
- |> > Should pass by value arguments be declared as "const" for
- |> > good coding style? Or is that nit picking?
-
- It's not a matter of declaration style, because the declaration must agree
- with the function definition.
-
- |> For scalar arguments, it doesn't really matter: The user can see that the
- |> argument is passed by value, so he doesn't care whether or not it is const.
- |> If you find it convenient, make it a const.
- |>
- |> For struct or class arguments, it may make a difference, and it is
- |> important to tell the user whether you will change the argument or not.
- |> Use const appropriately.
-
- For struct or class arguments passed by value, it's the same as scalars.
- Whether you change the by-value parameter or not, the parameter is destroyed
- when the function returns, so it doesn't matter to the caller.
- --
- Prescott K. Turner, Jr.
- Liant Software Corp. (developers of LPI languages)
- 959 Concord St., Framingham, MA 01701 USA (508) 872-8700
- UUCP: uunet!lpi!pkt Internet: pkt@lpi.liant.com
-