初学C++,一些摘抄

  • std::endl: is a special value called a manipulator.Writing endl has the effect of endling the current line and flushing the buffer associated with that device.Flushing the buffer ensures that all the output the program has generated so far is actually written to the output stream, rather than sitting in memory waiting to be written.

  • WARNING:: Programmers often add print statements during debugging.Such statements should always flush the stream(i.e. call std::endl).Otherwise, if the program crashes, output may be left in the buffer, leading to incorrect inferences about where the program crashed.

  • Like the output operator, the input operator(i.e. std::)returns its left-hand operand as its result, this expression(std::cin >> v1 >> v2) is equivalent to:(std::cin >> v1) >> v2;

  • Variables defined outside any function body are initialized to 0.(that is external variables ?)

  • local_str & global_str is initialized with "" by default.global_int is initialized with 0 and local_int is undefined.

  • When we define a reference, instead of copying the initializer's value, we bind the reference to its initializer.Once initialized, a reference remains bound to its initial object.There is no way to rebind a reference to refer to a different object.Because there is no way to rebind a reference, references must be initialized.

  • Because references are not objects, we may not define a reference to a reference.

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

  • **2014真题Directions:Read the following text. Choose the be...
    又是夜半惊坐起阅读 13,494评论 0 23
  • 你是怎么变得平庸的? 我记得小时候可不是这样,不是学习好就是逗猫遛狗,那个时候你还保留着精气神! 听说你也有一个怪...
    茶宁阅读 2,615评论 0 2
  • 人生五大投资: 1.第一大投资,是学习,学的多,成功概率就大,因此要多学习; 2.第二大投资, 社交,你交往的人狠...
    翰香书墨阅读 1,535评论 0 0
  • 我们每个人都有不同程度的自卑感,因为我们都想让自己更优秀,让自己过更好的生活。自卑感的存在并不是一件坏...
    梅蓝阅读 2,675评论 0 2

友情链接更多精彩内容