Should I redesign my code when collegues says so?

Posted by Kirill V. Lyadvinsky on Stack Overflow See other posts from Stack Overflow or by Kirill V. Lyadvinsky
Published on 2010-04-01T19:21:19Z Indexed on 2010/04/01 19:23 UTC
Read the original article Hit count: 551

Filed under:
|
|

I wrote a function recently that finds maximum of two ints. Here is a code:

int get_max (int(*a)(int(*)(int(*)()),int(*)(int(*)(int**))), int(*b)(int(*)
(int(*)()),int*,int(*)(int(*)()))){return (int)((((int(*)(int(*)(int(*)()),int(
*)(int(*)())))a)> ((int(*)(int(*)(int(*)()),int(*)(int(*)())))b))?((int(*)(
int(*)(int(*)()),int(*)(int(*)())))a):((int(*)(int(*)(int(*)()),int(*)(int(*)(
))))b));}

int main()
{
  int x = get_max(
    (int(*)(int(*)(int(*)()),int(*)(int(*)(int**)))) 500,
    (int(*)(int(*)(int(*)()),int*,int(*)(int(*)()))) 100 );

  cout << x << endl; // prints 500 as expected
  return 0;
}

It works fine, but my collegue says that I shouldn't use C style casts. But I think that all that modern static_cast's and reinterpret_cast's will make my code too cumbersome. Who's right? Should I redesign my code using C++ style casts or original code is OK?

© Stack Overflow or respective owner

Related posts about c++

Related posts about april-fools