Re: assigning values

  • From: "Littlefield, Tyler" <compgeek13@xxxxxxxxx>
  • To: <programmingblind@xxxxxxxxxxxxx>
  • Date: Sun, 16 Sep 2007 20:37:32 -0600

nods. was just checking. I've always just used ++. :)
Thanks,
Tyler Littlefield.
Vertigo head coder
"My programs don't have bugs, just randomly added features."
msn: compgeek134@xxxxxxxxxxx
email: compgeek13@xxxxxxxxx
aim: st8amnd2005
skype: st8amnd127
----- Original Message ----- From: "Sina Bahram" <sbahram@xxxxxxxxx>
To: <programmingblind@xxxxxxxxxxxxx>
Sent: Sunday, September 16, 2007 8:34 PM
Subject: RE: assigning values


Yes, with respect to y, but after both examples, x would obviously have the
value of x+1

Take care,
Sina

-----Original Message-----
From: programmingblind-bounce@xxxxxxxxxxxxx
[mailto:programmingblind-bounce@xxxxxxxxxxxxx] On Behalf Of Littlefield,
Tyler
Sent: Sunday, September 16, 2007 7:37 PM
To: programmingblind@xxxxxxxxxxxxx
Subject: Re: assigning values

so y=x++; would be y=x? because the incremented value hasn't been returned,
while y=++x; would = x+1?
Thanks,
Tyler Littlefield.
Vertigo head coder
"My programs don't have bugs, just randomly added features."
msn: compgeek134@xxxxxxxxxxx
email: compgeek13@xxxxxxxxx
aim: st8amnd2005
skype: st8amnd127
----- Original Message -----
From: "Sina Bahram" <sbahram@xxxxxxxxx>
To: <programmingblind@xxxxxxxxxxxxx>
Sent: Sunday, September 16, 2007 5:34 PM
Subject: RE: assigning values


The postincrement and preincrement operators change the value they are
applied to.

X++ is not the same thing as x+1

X++ is the same thing as

X = x+1

The difference between postincrement and preincrement is that in post
increment, x++ returns the previous value of x, before it's
incremented, and
++x returns the newly incremented value of x, but both assign that
incremented value to x.

Take care,
Sina

-----Original Message-----
From: programmingblind-bounce@xxxxxxxxxxxxx
[mailto:programmingblind-bounce@xxxxxxxxxxxxx] On Behalf Of Daniel
Dalton
Sent: Sunday, September 16, 2007 6:09 PM
To: ProgrammingBlind@xxxxxxxxxxxxx
Subject: assigning values

Hi,

I have worked out that the following will assign 12 to x and 12 to y:
int x =11, y;
y = ++x;
So why is x incremented when we are assigning x to y?
Like for example the following wouldn't change x:
y =x+1;
So does ++ behave different to + and then a variable or number?
Sorry if this doesn't make a lot of sense.
Basically I am asking.
How come when using ++ x is incremented but when using x+1 x doesn't
change.
Any help is greatly appreciated.

--
Daniel Dalton

http://members.iinet.net.au/~ddalton/
daniel.dalton47@xxxxxxxxx
__________
View the list's information and change your settings at
//www.freelists.org/list/programmingblind

__________
View the list's information and change your settings at
//www.freelists.org/list/programmingblind


__________
View the list's information and change your settings at
//www.freelists.org/list/programmingblind

__________
View the list's information and change your settings at
//www.freelists.org/list/programmingblind


__________
View the list's information and change your settings at //www.freelists.org/list/programmingblind

Other related posts: