Robert,

Since most of your questions are general Java questions and have
nothing to do with the Linux port of the JDK, can you please direct
them elsewhere? The USENET group comp.lang.java.programmer is probably
a good place to ask.

Thank you,
Matt Welsh, UC Berkeley

"Robert Simmons" <[EMAIL PROTECTED]> writes:
> This is a multi-part message in MIME format.
> 
> ------=_NextPart_000_0552_01BF1593.39A8C1C0
> Content-Type: text/plain;
>       charset="iso-8859-1"
> Content-Transfer-Encoding: quoted-printable
> 
> I was always the real proponent of type and instance safety in c++. for =
> example.=20
> 
> class Foo {
>   private BarClass  _bar;
> 
>   public const BarClass& getBar();
>   public setBar(const BarClass const &bar);
> }
> 
> This snippet guarantees that someone doesnt pull a getBar() then set the =
> return result. ie:=20
> 
> void main {
>    Foo f =3D new Foo();
>    BarClass c =3D new BarClass();
>    BarClass b =3D g.getBar();
>    b =3D c;  // DOH we just changed bar inside of the f instance
> }=20
> 
> Also it guarantees the following cant happen:=20
> 
> Foo::setBar(const BarClass const &bar) {
>   bar =3D new BarClass();  // DOH, just overwrote the var outside the =
> method
> }
> 
> Since everything in java is passed by reference this becomes even more =
> of an issue.=20
> Therefore can I do the following to achieve the desired safety ?=20
> 
> class Foo {
>   private BarClass  _bar;
> 
>   public final BarClass& getBar();
>   public setBar(final BarClass bar);
> }
> 
> Thanks for your time.
> 
> --rob


----------------------------------------------------------------------
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]

Reply via email to