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: Sat May 11 06:55:36 CEST 2024
Total time taken to generate the page: 0.02981 seconds
|