some sentenses from The c++ programming language chapter9

Where the unit of compilation is a file, all of a file must be recompiled
whenever a change (however small) has been made to it or to something on which it depends.

The keyword extern indicates
that the declaration of x in file2.c is (just) a declaration and not a definition (§4.9). Had x
been initialized, extern would simply be ignored because a declaration with an initializer is always
a definition.

Note that a
variable defined without an initializer in the global or a namespace scope is initialized by default.
This is not the case for local variables (§4.9.5, §10.4.2) or objects created on the free store

An inline function (§7.1.1, §10.2.9) must be defined – by identical definitions (§9.2.3) – in
every translation unit in which it is used.

By default, consts (§5.4) and typedefs (§4.9.7) have internal linkage.
A const can be given external linkage by an explicit declaration.

An unnamed namespace (§8.2.5) can be used to make names local to a compilation unit.

#include <iostream> / / from standard include directory
#include "myheader.h" / / from current directory
Unfortunately, spaces are significant within the< > or" " of an include directive:
#include < iostream > / / will not find <iostream>

A given class, enumeration, and template, etc., must be defined exactly once in a program.
#ifndef CALC_  ERROR_  H
#define CALC_  ERROR_  H
namespace Error {
/ / ...
}
#endif / / CALC_ERROR_H

a variable defined outside any function (that is, global, namespace, and class static
variables) is initialized before main() is invoked.

There is no guaranteed order of initialization of global variables in different translation units.

it is not possible to catch an exception thrown by the initializer
of a global variable

Often, a function returning a reference is a good alternative to a global variable.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值