Home » Developing U++ » U++ Developers corner » What does !! in e.g. FtpClient class mean?
Re: What does !! in e.g. FtpClient class mean? [message #39626 is a reply to message #39625] |
Wed, 10 April 2013 15:54   |
|
Sometimes cast is necessary, e.g.:
int func(int n){
return 1;
};
int func(bool b) {
return 2;
}
int main() {
int i=0;
func(i) != func(!!i); // there is a difference ;-)
func(!!i) == func((bool)i); // this is same ;-)
}
When you use '!' on anything else then bool, compiler will first cast it to bool (if possible) and then compute the negation. So !!x is equal to !( !( (bool)x ) ).
Honza
|
|
|
Goto Forum:
Current Time: Sun Jul 13 11:50:58 CEST 2025
Total time taken to generate the page: 0.05693 seconds
|