Why was function overloading added to C++?

前端 未结 6 1954
囚心锁ツ
囚心锁ツ 2021-02-03 21:03

I have a C background. I was just wondering why was function overloading added to C++? C doesn\'t have function overloading but C++ does, what was the need for it?

What

6条回答
  •  野趣味
    野趣味 (楼主)
    2021-02-03 21:28

    Would you prefer "selecting" one among abs/labs/llabs/fabs/fabsf/fabsl Or just abs()?

    Obviously, abs().

    So function overloading is a relief for programmers, most of the time, beside other advantages.

提交回复
热议问题