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++,一些摘抄
最后编辑于 :
©著作权归作者所有,转载或内容合作请联系作者
- 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
- 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
- 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...