[openbeos] Re: Pointer or reference?

  • From: "Waldemar Kornewald" <Waldemar.Kornewald@xxxxxx>
  • To: openbeos@xxxxxxxxxxxxx
  • Date: Sun, 28 Mar 2004 09:37:01 +0200 CEST

> By convention the Be API never expects strings to be passed in cases 
> where 
> the string is not changed by the callee (at least that is stated 
> somewhere). 
> Instead const char* is used. For functions that return a string via 
> reference 
> parameter, if there is a BString* version, then there's virtually 
> always also 
> a (char*, size_t) version.

Okay, then I will change it to const char *.

> > I really prefer the reference version. It could also state that the 
> > SetLabel() method does not have side-effect (i.e.: it does not 
> > modify 
> > string) which could be useful sometimes.
> 
> Huh? To ensure that something isn't changed, `const' is used. And it 
> works 
> for both, pointers and references.

I mean that we could just define this in our style-guidelines. If I 
pass the pointer to my string I expect evil things to happen, but if I 
pass the string object I do not know whether it is a reference or just 
a copy, so I do not expect changes being made to my string.

Bye,
Waldemar

Other related posts: