structure


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
18
19
struct test{

bool v0;
bool v1;
bool v2;
bool v3;
....

};

foo(const test T0, const test T1){

// how can i identify which member varaibe(T0.v0 or T0.v1 or ...) has been set to true with a min. code??
}
int main{
...
test T0, T1;
foo(T0, T1);
}


i appricaite each suggestion...
You must check them all yourself.

e.g.
1
2
if(T0.v0) /*...*/
//... 
If you had an array of bools, it would be easier to write code to test them.
Use a std::bitset, or use unsigned ints and bitmasks instead of bools.
Topic archived. No new replies allowed.