gpt4 book ai didi

时间:2019-03-08 标签:c++coutvsprintf()

转载 作者:塔克拉玛干 更新时间:2023-11-03 07:17:11 26 4
gpt4 key购买 nike

<分区>

在通过几个不同的来源学习了 c++ 之后,我发现了关于使用 cout 的相互矛盾的建议。/printf() .一位消息人士称 printf() ,我引用:

... does not provide type safety, so it is easy to inadvertently tell it to display an integer as if it were a character and vice versa. printf() also does not support classes, and so it is not possible to teach it how to print your class data; you must feed each class member to printf() one by one.

因此,对我来说更重要的是使用 printf() 的可读性因素。另一方面,另一个消息来源提到 cout , 使用重载运算符 << ,使用更多的指令来执行,因此在内存方面比大型程序更昂贵。虽然,说这话的人是系统程序员,每一点性能都是至关重要的。但是说我想从事游戏或应用程序开发。

  • 请问printf()之间的性能差异和 cout有那么重要吗?

  • 一般来说,我选择在应用程序中使用什么真的很重要吗?

感谢您的任何意见。

26 4 0