c ++ easy to confuse knowledge

C ++ confusing knowledge points
1 transfer function pointer and transfer the difference between the reference?
1 GT; uninitialized pointer may be defined, but the reference is not possible;
2 -; references can be combined with one entity, a plurality of entities can be combined with the pointer;
. 3 GT; the meaning of addition and subtraction are different. ++ pointer points to the byte offset pointer backward by type, referred to as +1 and, similarly;
. 4 & gt; evaluation size has a different meaning. Sizeof (pointer) is a pointer to the number of bytes occupied by the four 32-bit platform, the platform 8 to 64 (except for the array name), sizeof (reference) is an entity type of size to be used.
5 is not a null reference, but there is a null pointer;
6 levels of a plurality of pointers, but no reference in the multi-stage;
7 safer than a pointer reference, and need not be empty.
Note: You can also reference pointer
2 C ++ package:
hidden object properties and implementation details, only taps and objects interact with external interfaces, operating data and binding data and methods.
3 members must be initialized in the constructor to initialize the data members list:
reference data members const data members of a class type members (class does not have a default constructor).
4 object-oriented and process-oriented difference?
Process-oriented programming methods using a function (or processes) to describe the operation of the data, but the data separating function and its operation.
Object-oriented programming is to encapsulate data and the operation and objects to process them as a whole.
Process-oriented programming is a process-centric, it is difficult to maintain.
Object-oriented programming is a data-centric, data is relatively stable in terms of functionality, making it easier to maintain.
5 static keyword
Static local variables can modify global variables and functions.
When Decorative global variables and functions: file used to change the scope of a link attribute, which is available only in the current file.
6 modified local variables:
1. Open the static region;
life cycle time of the whole operation of the function;
3. Default is initialized to 0;
4. Variable memory function, i.e., the last value saved after each call;
5. First create a function is called, the constructor is called only once.
7 member variables and functions to modify classes:
static members are shared by all objects that do not belong to examples
8 can use the class name: the static member or object (.static member functions) to access a static class taps price class member static member variables must be declared in the class defined outside the class, without defining the static keyword
9 static class member functions of this pointer no default, and therefore can not be used where non-static member.
10 ordinary members of the same class with static members.
They also have 11 private3 public access level protected, and also has a return value, const modifier, and other parameters.
12. Compatibility rules assigned
subclass object can be directly assigned to the parent object.
Parent objects can not be directly assigned to child objects.
Parent pointers or references may be directly pointing object subclass.
Subclass pointer or reference can not directly point to the parent object of a given class (strong convertible).
13. Polymorphism
concepts: polymorphism refers to the operation of various different objects exposed to different messages.
Description: When a pointer to the base class or subclass references to objects, it can only access the derived class inherits from the base class members, and new members can not access the derived class. Refer to virtual function can solve this problem.
Dynamic binding conditions: providing a base class virtual function member functions; when the virtual function call, the call must be a pointer or reference to the base class; must override the virtual function (meet these requirements) in the derived class.
14. Function overloading, the same name hidden, rewriting (overwriting / rewritable)
function overloading: the same function name, the same scope, a list of different parameters (type, number, sequence)
of the same name hidden: in a base class, a derived in class, having the same function name
covers / cover: a base class, a derived class, all the virtual function, the same function name, the same list of parameters, the same function return values (covariance excluded)
covariance : the return value is a pointer or reference to the base class, and a pointer or reference to a derived class.
15. When it is desired to set the destructor virtual function
polymorphic scenario, when a pointer pointing to the base class or a derived class object reference, since a pointer to the base class and calls the base class destructor. In this case, the derived class belonging to a space not released, resulting in a memory leak, it is necessary to set the base class destructor in this scenario. As a virtual function, when calling the destructor will call the destructor derived class.
16. When our compiler synthesis default constructor?
1> A has a class defined with its own default constructor. Class B definition object are not displayed but contains own constructor class A. In this case, the compiler will default constructor prior Constructor B synthetic class A to invoke.
2> If the class B and class D is inherited relations (class D: public class B), Class B contains its own default constructor, the class D has no constructor, the compiler will synthesize a default constructor class D, and B calls the class has a default constructor.
3> virtual inheritance, the derived class do not show if the constructor, the compiler, and point to the virtual base table pointer four bytes of the object when the object is constructed for the synthesis of the default constructor.
In polymorphisms, if the base class virtual functions, but does not show the derived class's constructor function definition, the compiler will default constructor for the synthesis, and point virtual table (vtable) storing pointers to objects the first four bytes.
17. Creating virtual table
base class: The virtual function declaration order, the virtual address into the virtual function table of the disposable, the final position is 0.
Derived classes: first copy of the base class virtual table
if the derived class overrides some of the base class, the derived class virtual function of the position of the same inexpensive table modify the derived class has its own virtual function address.
If the derived class to add a different base class virtual function, it will be placed at the end of the end table and the virtual 0.
18. STL of six components:
a container, iterators, algorithms, adapters, spatial configuration, an analog function (function object)
19. Executing
pre-compiled assemblies link to perform
pre-processing: delete a comment, macro substitution, conditional compilation, include the header file, add line numbers, file names, and so on.
Compile: lexical analysis, syntax analysis, semantic analysis, optimization, and then generates the corresponding assembly code
compilation: the binary instructions into assembly code programmed computer can perform.
Links: export symbol table, the redirection address table, the symbol table bit resolution
to execute: a specific code execution logic
20. Exception handling
in C:
1> terminate the program
2> indicates a return

Guess you like

Origin www.cnblogs.com/blogst/p/11349933.html