Should I redesign my code when collegues says so?
- by Kirill V. Lyadvinsky
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?