Search the archives!
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
c = c++ problem
- From: cvandeso@xxxxxxxx (cvandeso@xxxxxxxx)
- Subject: c = c++ problem
- Date: Fri, 31 Mar 2000 15:40:31 +0100
It's exactly done like that !
c =3D c++;
is treated as
class C {
int c =3D 10;
c =3D inc(); // c is set to 10 again
int inc() {
int c_ =3D 0;
{
c_ =3D c;
c =3D c + 1; // c is set to 11
}
return c_; // but c_ is 10
}
}
and
c =3D ++c;
is treated as
class C {
int c =3D 10;
c =3D inc(); // c is set to 11
int inc() {
int c_ =3D 0; // temp var
{
c =3D c + 1; // c is set to 11
c_ =3D c;
}
return c_; // and c_ is 11
}
}
Regards,
Carlo
Consulting Engineer.
Rodrigo de Almeida Sodr=E9 <rodrigo@xxxxxxxxxxxxxxxx> on 31/03/2000 14:=
27:54
To: advanced-java@xxxxxxxxxxxxxxxx
cc: (bcc: Carlo Van de Sompel/ISD/Anhyp/BE)
Subject: RE: c =3D c++ problem
=
Content-type: text/plain; charset=us-ascii
Well, maybe
c = c++;
is treated as
class C {
int c = 10;
int inc() {
int c_ = c;
c = c + 1;
return c_;
}
}
Rodrigo A. Sodre
Analista de Sistemas
Foton Informatica e Servicos
(061) 328-5060 R:243
rodrigo@xxxxxxxxxxxxxxxx
> -----Original Message-----
> From: Pat Ryan [mailto:ryanxpx@xxxxxxxxxx]
> Sent: Friday, March 31, 2000 10:15 AM
> To: Rajesh Gupta; advanced-java@xxxxxxxxxxxxxxxx
> Subject: Re: c = c++ problem
>
>
>
> I saw the other responses, and while they are correct, I
> agree with Rajesh,
> after the assignment, just what is being incremented? It
> would appear to
> be the variable c.
>
> However, the result you are seeing would indicate that the
> right hand side
> of the assignment is a copy of c.
>
> -Patrick.
>
>
>
>
>
> "Rajesh Gupta" <rajesh_gu@xxxxxxxxxxx> on 03/31/2000 03:14:08 AM
>
> To: advanced-java@xxxxxxxxxxxxxxxx
> cc:
> Subject: c = c++ problem
>
>
> hello all
>
> i have a simple problem
>
> int c = 10;
> c = c++;
>
> and c is still 10 !
> if use c = ++c; this gives me 11 this is quite obvious.
> whats the logic behind c = c++ giving original value of c this ?
>
> thanks in advance
>
> Rajesh
>
> ______________________________________________________
> Get Your Private, Free Email at http://www.hotmail.com
>
>
> ---
> To unsubscribe, mail advanced-java-unsubscribe@xxxxxxxxxxxxxxxx
> To get help, mail advanced-java-help@xxxxxxxxxxxxxxxx
>
>
> Patrick H. Ryan
> Senior Design Engineer
> Hobart Technology Center
>
>
>
>
> ---
> To unsubscribe, mail advanced-java-unsubscribe@xxxxxxxxxxxxxxxx
> To get help, mail advanced-java-help@xxxxxxxxxxxxxxxx
>
---
To unsubscribe, mail advanced-java-unsubscribe@xxxxxxxxxxxxxxxx
To get help, mail advanced-java-help@xxxxxxxxxxxxxxxx
---
To unsubscribe, mail advanced-java-unsubscribe@xxxxxxxxxxxxxxxx
To get help, mail advanced-java-help@xxxxxxxxxxxxxxxx
- Prev by Date: Open Research Position: Execution-Driven Performance Analysis for Distributed/Parallel Systems
- Next by Date: applet signing
- Previous by thread: c = c++ problem
- Next by thread: swing question
- Index(es):