repeat an block code


Hi all,

if i have the following code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17

if(condetion){
assignment 0;
blockcode;
}
els if(condetion){
assignment 1;
blockcode;
}
else if(condetion){
assignment 3;
blockcode;
}
else{
assignment 4; // here i dont need the blockcode.
}


is there any other technique to aviode writing the same blockcode for almost cases??

thanks for each help
use functions http://www.cplusplus.com/doc/tutorial/functions/
unles you consider one line a blockcode. then I don't think there is any way.
Last edited on
Why don't you post the actual code so we can have a look?
closed account (S6k9GNh0)
Actual code would be nice and effecient. But from what I can see, I suggest a use of functions and a switch to be most convenient.
I agree; functions and a switch statement are definitely the way to go.
Topic archived. No new replies allowed.