majcos的专栏

努力寻找方向

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.

阅读更多
想对作者说点什么? 我来说一句

The c++ programming language习题答案

2008年08月28日 103KB 下载

没有更多推荐了,返回首页

不良信息举报

some sentenses from The c++ programming language chapter9

最多只允许输入30个字

加入CSDN,享受更精准的内容推荐,与500万程序员共同成长!
关闭
关闭