| jumper007 (302) | |||||
I have this part of a program, where the matrix is initialised with n x n values of "true".
The thing is that I don't get how the
PS: I know that a > b ? a : b returns 'a' if 'a' is greater than 'b' and 'b' if 'b' is greater than or equal to 'a'.
| |||||
|
Last edited on
|
|||||
| Moschops (5961) | |
adc[i][j] = (t ? true : false);Does that make it clearer? | |
|
|
|
| vlad from moscow (3112) | |
|
You did not show what is the type of variable t. But in any case I think that it is some scalar type. In C/C++ there is an implicit conversion of a scalar type to the bool type. If the value of a scalar type is equal to zero then it is converted to bool false. Otherwise it is converted to bool true. In fact you could write simply adc[i][j] = t; or adc[i][j] = t != 0; | |
|
|
|
| jumper007 (302) | |||
Actually I did mention...
Anyway, thanks to both, I got it now :) | |||
|
Last edited on
|
|||
| Alx101 (73) | |
iFILE >> t; basicly puts the contents of t to the file designated in the initializiation of iFILE.
| |
|
|
|
| Moschops (5961) | |||
| |||
|
Last edited on
|
|||
| jumper007 (302) | ||
@Moshops
True, indeed it could have been a char, string or long type, but still, I find it quite weird to talk about that. I mean, the posibility that someone would call a variable of type char or string to assign it to a boolean two dimensional array is about 0%. And even if I would have defined that variable t as char, as it takes values of 0 and 1, it would have been still interpreted as a numerical type by the compiler. Actually the variable t could be even declared as size_t, and still would have had the same effect in the program.I won't develop my ideas further because it's quite a waste of time. Thanks anyway. Best of wishes, ~ Raul ~ | ||
|
|
||