C++ Knowledge series Template & Class】的更多相关文章

Function Function is composed of name, parameter (operand, type of operand), return value, body with another adornment like: inline, virtual, static, const, throw(). 我们必须在调用函数之前,就声明该函数否则会引起编译错误. 函数声明由函数返回类型,函数名和参数表构成. 这三个元素被称为函数声明function declaration…
Programming language evolves always along with Compiler's evolvement. 1. The C++ Object Model: Stroustrup's original (and still prevailing) C++ Object Model is derived from the simple object model by optimizing for space and access time. Non-static d…
Everything has its lifecycle, from being created to disappearing. Pass by reference instead of pass by value 尽量用“传引用”pass reference 而不用“传值” pass value c语言中,什么都是通过传值来实现的,c++继承了这一传统并将它作为默认方式.除非明确指定,函数的形参parameter总是通过“实参argument的拷贝”来初始化的,函数的调用者得到的也是函数返回…
Thank to the pepole who devote theirself to the common libs. STL(http://www.cplusplus.com/reference/) 旧的C++头文件名如<iostream.h>将会继续被支持,尽管它们不在官方标准official standard中.这些头文件的内容不在名字空间std中.No _STDBEGIN (namespaces std {}and _STDEND. 新的C++头文件如<iostream>…
Pepole who make a greate contribution on common libaraies deserve our respect. Component(Widget) / STL / Container(Collection) 合成不会强迫我们的程序设计进入继承的分级结构中has-a relationship.同时,合成显得更加灵活,因为可以动态选择一种类型(以及行为),而继承要求在编译期间准确地知道一种类型. Java的工具(实用程序)库提供了一些“集合类”(亦称作“…
JVM & Bytecode Has-a or Is-a relationship(inheritance or composition) 如果想利用新类内部一个现有类的特性,而不想使用它的接口,通常应选择合成.也就是说,我们可嵌入一个对象,使自己能用它实现新类的特性.但新类的用户会看到我们已定义的接口,而不是来自嵌入对象的接口.考虑到这种效果,我们需在新类里嵌入现有类的private对象.有些时候,我们想让类用户直接访问新类的合成.也就是说,需要将成员对象的属性变为public.成员对象会将自…
Programming has its own methodology. Layering is everywhere in real life,this why the pruchase and sale exist. Layering, Insert additional indirection 通过分层layering/add indirection来体现 "有一个" 或 "用...来实现’ composition /composite 使某个类的对象成为另一个类的数据…
Programming language evolves always along with Compiler's evolvement On the Cusp of the Object Model Templates Template are now the foundation for generic programming ( the Standard Template Library). Template are used in memory allocation strategies…
Programming language evolves always along with Compiler's evolvement The Semantics of Data The size of an empty base class or an empty derived class inherited from an empty base class is not 0. For some reason: virtual pointer to virtual function tab…
Inheritance The pointer or reference to base class can address/be assigned with any of the classes derived from base class with virtual functions through mechanism of dynamic binding. There are three ways to support polymorphism: through implicit con…