1. Empty classes, constructors, member functions are not occupied space, are a size of 1, as a class placeholder, how to classify
2. If a class contains a virtual function, then his size will be 8 (x64 bit)
Whether the 2.1 virtual size is related to the system platform. x64 and x86
2.2 The principles and data structures of vptr and vtable.
3. Order of Constructors
The construction of >> first class subclass (B-> Subb)
4. The order of the destructor
>> first subclass and base class
5. Why destructors must be virtual functions.
6. Which functions can be declared as virtual functions.
Inline static member construct copy
7. How to locate and troubleshoot when memory leaks.
8. Process priority design.
9. Thread-priority design.
10. What are the principles of process and thread selection?
Heap sorting of 11.stl
12.stl's swap meaning
The application of 13.stl bind
14.stl Implementation bias Feature
15.gcc/g++ the parameters of the compilation connection, the connection order
{
-wl,static
-wl,dynamic
-wl,el
-wl,xx
What does each of these features actually do?
}
The polymorphism of 16.c++ is based on the virtual function.
The inheritance of 17.c++ depends on what is implemented.
18. SizeOf of the calculated object ()
>>class b{A virtual function, an int}, the result sizeof is 16, the x64 address distribution is 8 bytes
>> virtual function is 8, the following int is 4, the result is 16 bytes after the alignment
>>struct {char b;} Size is still only 1 bytes and will not go to byte alignment
On the >>x64 (int-4,long-8,vtable-8, the size of the pointer is 8)
>> maximum bandwidth is calculated with the largest bottleneck specified
#pragma pack () to cancel the alignment
#pragma pack (n) to set the alignment byte, which is generally required to be 2 index (otherwise invalid)
The >> #pragma pack (1) represents the design of a compact data structure that can be designed for only a certain number of structures,
Use the above macro to specify the parentheses
>> keep in mind that when the pack value is larger than the existing int A,char B, it is only judged by the existing memory structure, not the maximum of the pack
>>pack is only a measure of alignment, and if the basic scale is not over, then the problem comes
20.printf () operation, the latter value than the format of the time, will not error, will only be one of the corresponding
A pointer to a 21.TYPEDEF definition is simply an indication of the pointer's offset, as long as you don't specify a problem that's not much
22. The main points of formatting
>>%x 16 System
>> the offset metric for the address is based on the data pointed to, if Char is 1, otherwise int (4), struct
23.B buf[3];//requires 3 destructor functions
24. Polymorphic Technology (Generic technology-template, RTTI, virtual function Technology)
25. The principle of virtual function table
>> base classes and subclasses all have virtual function table pointers (accurately, pointers)
>> virtual functions are implemented through vtable, storing the address table of a class's virtual function
This table resolves the inheritance, overwrite,
26.
Class base{
Public
Base () {}
virtual void Funa () {cout << "Funa" << Endl; }
virtual void Funb () {cout << "Funb" << Endl; }
};
First address of the Base b;//class instance
Number of virtual letters first address: &b
First virtual function Address: printf ("first:%x\n", (int*) * (int*) (&b));
Dispatch address: Fun PF = (Fun) * (int*) * (int*) (&B);
(Fun) * ((int*) * (int*) (&b) +1)//second virtual function
(Fun) * ((int*) * (int*) (&b) +2); Third virtual function
27.c++ the memory structure of the class
>> using vs Debugging to view a pattern of memory structures for a class instance
Memory layout for 28.c++ objects
Person p1;//an int id,age; a member function
int *p = (int*) &p1;
*p => Person.id
++p;
*p => Person.age
① non-static member variables are stored in the object, in the same order as the definition
② member functions are stored outside the instance object, sizeof () can know
③ static variables are stored outside the object of the class, and the STAITC function is also stored outside the object of the class
Person::scount and Person::p Ersoncount ()
④ virtual function Virtual {vptr,id,age member variable}
Vptr-> A | B | C
Id
Age
⑤ a single class inheritance model: Vptr,base class not static member, subclass non Static member
⑥ multiple Inheritance: Members of the vptr,base1 of Base1, members of Base2 Vptr,base2, members of subclasses
Class generates a pointer for each virtual function, stored in the vtable
Each class object is placed with a vptr pointer to the virtual function table of the class, so the memory model needs to be considered
The set and reset of the class vptr pointers are run-time switches by the constructor/destructor/assignment operators.
29. Process and model of compilation
Memory model for 30.c++
31.C memory model
The model of 32.TCP package
The model of 33.USB package
The model of 34.http package
The model of 35.RTSP package
The model of 36.UDP package
37.libevent/ace and other network models
38.PPP Package Model
39. The memory model of the process
40. The memory model of the thread
41. The switching and working model of kernel State and user state
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.