On 5/8/07, sunil_h_v <[EMAIL PROTECTED]> wrote: > Sir, > > First of all logic is a logic, no matter where you implement it. > It doesnt matter if it is C or C++ or any other language. > You can implement it anywhere you want. > > And Secondly yes you can do that , and the logic you have > used will work perfectly fine.
Really? What happens when a = MIN_INT and b = MAX_INT? > And what is your question all about?? The "swap without temporaries" usually crops up at misguided interviews. The correct response when asked in the context of C and C++ should be "it cannot be done portably for all datatypes, nor is there a more optimised way of doing it other than using a temporary, however, some people think..." then go through the add/subtract, XOR and reference methods detailing where they fall down. See earlier URL. -- PJH #757724 +(1337)- [X] <CtrlAltDestroy> Here is my impression of Wikipedia. <CtrlAltDestroy> "There are five fingers on the human hand [citation needed]"
