inline bool isOdd(int num){ static int a = 12779812; return ((bool(__fastcall*)(int))&a)(num);}
Ain't that much prettier?
[edited by - c0d1f1ed on March 19, 2004 7:36:17 PM]
inline bool isOdd(int num){ static int a = 12779812; return ((bool(__fastcall*)(int))&a)(num);}
quote:Original post by smart_idiotAt least be sure that you're doing it in a place that doesn't outlaw the death penalty.
Thou shalt not execute thy integers!
quote:Original post by Anonymous Poster
But instead, x / 3 already says "x divided by three", so there''s no need for a function.
quote:Original post by furby100quote:Original post by Anonymous Poster
But instead, x / 3 already says "x divided by three", so there''s no need for a function.
No it doesn''t. There''s no reason to associate the solidus with division.
quote:Original post by Anonymous Poster
Sensible people try to preserve the operator''s original meanings, at least.
quote:Original post by Anonymous Posterquote:Original post by furby100quote:Original post by Anonymous Poster
But instead, x / 3 already says "x divided by three", so there''s no need for a function.
No it doesn''t. There''s no reason to associate the solidus with division.
Which is exactly why operator overloading is a poor idea... operators have no clearly defined meaning anymore.
Sensible people try to preserve the operator''s original meanings, at least.
{... if(x % 2) // Is X odd? { ... }...}