Should I redesign my code when my colleague 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:43 UTC
Read the original article Hit count: 654

Filed under:
|
|

I wrote a function recently (with help of one guy from SO) that finds maximum of two ints. Here is the code:

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

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

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

It works fine, but my colleague 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 is original code OK?

EDIT: For those who marks this question as not a question I'll try to be more clear: should I use C++ style cast instead of C style cast in the code above?

© Stack Overflow or respective owner

Related posts about c++

Related posts about april-fools