C ++ / C中使用的函数有哪些应用? [英] What are the applications of functions used in C++/C?

查看:75
本文介绍了C ++ / C中使用的函数有哪些应用?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对c ++中函数的优点和用法感到困惑。我在网上搜索了应用程序,却找不到其他地方。 Plz在这件事情上尽快指导我>> ....



我尝试过的事情:



我一直在网上搜索但是找不到这个主题的答案。

i am confused about the advantages, uses of functions in c++. I searched the net for the applications and found nowhere else. Plz guide me as soon as possible in this matter>>....

What I have tried:

I searched the net all the time but found nowhere else the answer of this topic.

推荐答案

功能(用任何语言) )使您能够编写一次代码并在同一应用程序中的许多位置使用它。这意味着三大优势:

1)可靠性。让它工作一次。非常非常好地测试它。然后你可以反复使用它而无需再次测试 - 只需要调用它的代码。

2)可维护性。如果需要更改,只需要在一个地方进行更改(并再次进行非常,非常好的测试),以影响使用它的所有地方。因此,如果您发现了一个错误,它会在任何地方修复,而不需要找到使用相同代码的所有地方并在那里进行更改 - 这意味着您不会错过任何错误,或者在复制修复程序时出错。 br />
3)空间。没有那么重要的是,只有一个代码副本会使整个应用程序变得更小,代价是额外的执行时间很少。
Functions (in any language) enable you to write code once and use it from many places in the same application. That means three big advantages:
1) Relaibility. Get it working once. Test it very, very well. Then you can use it over and over without needing to test it again - just the code that calls it.
2) Maintainability. If it needs a change it only needs to be changed in one place (and again tested very, very well) to affect everywhere that uses it. So if you find a bug, it's fixed everywhere without you needing to find all the places that the same code was used and change it there as well - which means you don;t miss any, or make a mistake in copying the fix.
3) Space. Less important than it was, having only one copy of the code makes the whole application smaller, at the cost of a tiny amount of extra execution time.


这篇关于C ++ / C中使用的函数有哪些应用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆