visual c++ - How can i get a setMethod to input value one time, while being in a loop? is it impossible? -
a loop has setmethod
private variable. want set-method add value in first turn of loop, , stop. how can that?
code:
for(int x = 0; x > 5; x++) { setnum(5); cout << getnum(); setnum(getnum() -1); }
this code should output: 1 2 3 4 5
but when doing it outputs: 5 5 5 5 5
setnum(5)
resetting.
how prevent it? setnum(5)
inside loop.
insted of > put x < 5 , pass x parameter setnum() method.
for(int x = 0; x < 5; x++) { setnum(x); }
Comments
Post a Comment