《The C++ Programming Language, Special Edition》的原文摘录

  • [2.13.4]2.Whether all string literals are distinct (that is, are stored in nonoverlapping objects) is implementation-defined. The effect of attempting to modify a string literal is undefined. (查看原文)
    Marmot 2011-10-09 09:20:11
    —— 引自第90页
  • A namespace is a scope. Thus, "namespace" is a very fundamental and relatively simple conecpt. The larger a program is, the more useful namespaces are to express logical separations of its parts. Ordinary local scopes, global scopes, and classes are namespaces. (查看原文)
    Marmot 2011-10-20 17:40:39
    —— 引自第168页
  • Ideally, every entity in a program belongs to some recognizable logical unit("module").Therefore,every declaration in a nontrivial program should ideally be in some namespace named to indicate its logical role in the program. The expception is main(), which must be globa in order for the run-time environment to recognize it as special. (查看原文)
    Marmot 2011-10-20 17:47:27
    —— 引自章节:8.2
  • It is often a good idea to keep local synonyms as local as possible to avoid confusion. (查看原文)
    Marmot 2011-10-20 17:47:27
    —— 引自章节:8.2
  • The purpose of interfaces is to minimize dependencies between different parts of a program. Minimal interfaces lead to systems that are easier to understand, have better data hiding properties, are easier to modify, and complie faster. (查看原文)
    Marmot 2011-11-02 10:49:32
    —— 引自第173页
  • however,for most problems I face,this solution is also massive overkill. (查看原文)
    Marmot 2011-11-02 10:49:32
    —— 引自第173页
  • Decide which modules you want;partition the program so that data is hiden within modules. (查看原文)
    Marmot 2011-11-04 08:47:41
    —— 引自第184页
  • Over the years, the emphasis in the design of programs has shifted from the design of procedures and toward the organization of data. Among other things, this reflects an increase in program size. A set of related procedures with the data they manipulate is often called a module. The programming paradigm becomes: Decide which modules you want; partition the program so that data is hidden within modules. (查看原文)
    Marmot 2011-11-10 20:22:36
    —— 引自第26页
  • [2.13.4]1.An ordinary string literal has type “array of n const char” and static storage duration. (查看原文)
    Marmot 2011-11-11 17:21:25
    —— 引自第190页
  • the one-definition-rule: [1] they appear in different translation units,and [2] they are token-for-token identical,and [3] the meaning of those tokens are the same in both translation units. The best defense against this kind of hackery is to make headers self-contained as possible. (查看原文)
    Marmot 2011-11-17 14:01:04
    —— 引自第203页
  • The initialization of non-local static variables is controlled by whatever mechanism an implementation uses to start up a C++ program. This mechanism is guaranteed to work properly only if main() is executed. Consequently, one should avoid nonlocal variables that require run-time initialization in C++ code intended for execution as a fragment of a non C++ program. ADVICE [12]Avoid nonlocal objects that require run-time initialization in code intended for use as part of non-C++ programs. (查看原文)
    Marmot 2011-11-17 19:05:03
    —— 引自第218页
  • [3.6.2.2]An implement is permitted to perform the initialization of an object of namespace scope with static storage duration as a static initialization even if such initialization is not required to be done statically,provided that: ---the dynamic version of the initialization does not change the value of any other object of namespace scope with static storge duration prior to its initialization,and ---the static version of the initialization produces the same value in the initialization as would be produced by the dynamic initialization if all objects not required to be initialized statically were initialized dynamically. (查看原文)
    Marmot 2011-11-17 19:05:03
    —— 引自第218页
  • [3.6.2.3]It is implementation-defined whether or not the dynamic initialization of an object of namespace scope is done before the first statement of main. If the initialization is deferred to some point in time after the first statement of main,it shall ocuur before the first use of any function or object defined in the same translation unit as the object to be initialization. (查看原文)
    Marmot 2011-11-17 19:05:03
    —— 引自第218页
  • [6.7.4] The zero-initialization of all local objects with static storage duration is performed before any other initialization takes place. A local object of POD type with static storage duration initialized with contant-expressions is initialized before its block is first entered. An implementation is permitted to perform early initialization of other local object with static duration storage under the same conditions that an implementation is permitted to statically initialize an object with static storage duration in namespace scope. Otherwise such an object is initialized the first time control pass through its declaration; such an object is considered initialized upon the completion of its initialization. If the initialization exits by throwing an exception, the initialization is not ... (查看原文)
    Marmot 2011-11-17 20:29:29
    —— 引自第219页
  • The storage specifier mutalbe specifies that a member should be stored in a way that allows updating -- even when it is a member of a const object. In other words, mutable means "can never be const". (查看原文)
    Marmot 2011-11-21 21:08:49
    —— 引自第232页
  • [7.1.5.1]Except that any class member declared mutable can be modified,any attempt to modify a const object during its lifetime results in undefined behavior. (查看原文)
    Marmot 2011-11-21 21:08:49
    —— 引自第232页
  • [7.1.1.8]The mutable specifier can applied only to names of class data members and cannot be applied to names declared const or static, and cannot be applied to reference members (查看原文)
    Marmot 2011-11-21 21:08:49
    —— 引自第232页
  • [12.6.2.2]Names in a mem-initializer-list are looked up in the scope of the constructor's class and, if not found in that scope, are looked up in the scope containing the constructor's definition. Unless the mem-initializer-id names a nonstatic data member of the constructor's class or a direct or virtual base of that class, the mem-initializer is ill-formed.A mem-initializer-list can initialize a base class using any name that denotes that base class type. (查看原文)
    Marmot 2011-11-22 21:37:39
    —— 引自第247页
  • The members' constructors are called before the body of the containing class' own constructor is executed. the constructors are called in the order in which they are declared in the class rather than the order in which they appear in the initializer list. To avoid confusion, it is best to specify the initializers in declaration order. The member destructors are called in the reverse order of constructor. [12.6.2.5]initialization shall proceed in the following order: --- First, and only for the constructor of the most derived class as describe below, virtual base classes shall be initialized in the order they appear on a depth-first left-to-right traversal of the directed acyclic graph of base classes, where "left to right" is the order of appearance of the base class names in the derived c... (查看原文)
    Marmot 2011-11-22 21:37:39
    —— 引自第247页
  • [12.8]The implicitly-defined copy constructor for a class perform a memberwise copy of its subobjects.The order of copying is the same as the order of initialization of bases and members in a user-defined constructor.Each subobject is copied in the manner appropriate to its type: ------ if the subobject is of class type,the copy constructor for the class is used; ------ if the subobject is an array, each element is copied, in the manner appropriate to the element type; ------ if the subobject is fo scalar type, the bulit-in assignment operator is used. (查看原文)
    Marmot 2011-11-24 18:05:22
    —— 引自第245页
<前页 1 2 3 4 5 后页>