Someone mentioned accessor methods?

Steven T. Hatton hattons at globalsymmetry.com
Tue Mar 9 20:54:03 UTC 2004


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Top-posting? For shame! ;-)

My question becomes; what should accessor methods look like in C++?  In Java 
we write 
[public] void setMemberName(type memberName){..};
 
[public] type getMemeberName(){return memberName;}

or 

[public] boolean isMemberName(){ return memberName;}

Note that I used memberName as the parameter name.  That is not a fixed 
practice in Java - but it should be. :-)

[public] void setMemberName(type memberName)
{ 
	this.memberName = memberName; 
};

Works just fine in Java, but I don't believe the same can be done in C++.  
Correct?

Also, C++ers tend to simply use the name of the member field as the name of 
the retrieval (getter) method.  Agreed? 

What about passing a reference verses passing a value; to the mutator 
(setter)?; as the return value?  

What about constness? 

Does someone have a paradigm for this they would like to share?

STH

On Tuesday 09 March 2004 03:16 am, Sascha Herrmann wrote:
> Hi Steve,
>
> yes we had that discussion just some weeks ago. It started here:
>
> http://www.kdevelop.org/forum/read.php?f=2&i=10855&t=10814&v=f
>
> As conclusion we decided to wait untill the NEW parser is ready.
> bye sascha
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.2 (GNU/Linux)

iD8DBQFATiDXwX61+IL0QsMRAkDeAKDhuE8jJUBryRbYV6O07vUO0SeGNgCgyqj2
MsG8D2iRLC24UY7XEBkvGlw=
=nYgp
-----END PGP SIGNATURE-----




More information about the KDevelop-devel mailing list