increasing variable
This may seem a pretty basic question but how could you detect if a variable was increasing/descreasing? Its not
if (variable++) is it?
Thanx,
ViPeR
The easiest way I can think of would be to have another variable which is initilised with the origonal value of the other variable and compare their values periodically.
eg.
if (num1 != num2)
{
/* do whatever
}
eg.
if (num1 != num2)
{
/* do whatever
}
variables don''t just increase and decrease on their own. You have to do that for them, so the logical thing would be to have a variable that represents it''s last value
old_y = y;
y++;
or to have a variable that represents it''s change
dy = -5;
y += dy;
old_y = y;
y++;
or to have a variable that represents it''s change
dy = -5;
y += dy;
quote: Original post by Jim_Ross
...
old_y = y;
y++;
...
Unless I am very mixed up you could also do this as:
old_y = y++;
Because the postfix operator was used, the origional value of y is returned with y being incremented. This is one feature of C++ I love, so I thought I would point it out
--------------------
"Very funny Scottie, now beam down my clothes."
www.trak.to/rdp
--------------------
You are not a real programmer until you end all your sentences with semicolons; (c) 2000 ROAD Programming
You are unique. Just like everybody else.
"Mechanical engineers design weapons; civil engineers design targets."
"Sensitivity is adjustable, so you can set it to detect elephants and other small creatures." -- Product Description for a vibration sensor
You are not a real programmer until you end all your sentences with semicolons; (c) 2000 ROAD Programming
You are unique. Just like everybody else.
"Mechanical engineers design weapons; civil engineers design targets."
"Sensitivity is adjustable, so you can set it to detect elephants and other small creatures." -- Product Description for a vibration sensor
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement