Re: Choosing function parameter types - pointers or objects?



Keith Thompson said:

Richard Heathfield <invalid@xxxxxxxxxxxxxxx> writes:
ballpointpenthief said:
I know this question is a bit vague, but I was wondering about any
rules / guidelines / style issues, for when to use pointers, and when
not to, in your function parameters?

If it's a native type (int, short, long, double, that sort of thing),
pass it in raw unless you need to hack its value. Anything else - structs
and stuff - pass a pointer.

I wouldn't hesitate to pass a *small* structure directly.

I would. Small structures have a habit of growing larger. :-)

--
Richard Heathfield
"Usenet is a strange place" - dmr 29/7/1999
http://www.cpax.org.uk
email: rjh at above domain (but drop the www, obviously)
.



Relevant Pages

  • Re: Choosing function parameter types - pointers or objects?
    ... rules / guidelines / style issues, for when to use pointers, and when ... not to, in your function parameters? ... If it's a native type, pass ...
    (comp.lang.c)
  • Re: Choosing function parameter types - pointers or objects?
    ... rules / guidelines / style issues, for when to use pointers, and when ... not to, in your function parameters? ... If it's a native type (int, short, long, double, that sort of thing), pass ...
    (comp.lang.c)
  • Re: Choosing function parameter types - pointers or objects?
    ... rules / guidelines / style issues, for when to use pointers, and when ... not to, in your function parameters? ... If it's a native type, ... I do accept struct tm by value from localtimeto populate my local struct tm when I'm playing with time stuff. ...
    (comp.lang.c)
  • Re: One more question on TSTs
    ... B and D are again siblings. ... >> figuring out how to have a flat layout when the structs contain pointers. ... >> memory location. ...
    (microsoft.public.dotnet.languages.vc)
  • Re: One more question on TSTs
    ... B and D are again siblings. ... >> figuring out how to have a flat layout when the structs contain pointers. ... >> memory location. ...
    (microsoft.public.vc.language)