美文网首页
初学C++,一些摘抄

初学C++,一些摘抄

作者: melouverrr | 来源:发表于2016-05-24 21:20 被阅读19次
    • 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.

    相关文章

      网友评论

          本文标题:初学C++,一些摘抄

          本文链接:https://www.haomeiwen.com/subject/regzrttx.html