Com Study Notes
Learning materials: the essence of COM
Record for now, and then sort
Interface inheritance)
Chapter 1 COM is a better C ++
Disadvantages of code reuse: To achieve reuse, you must understand the design and style of other developers ......,
// This sentence is very good, and I have gone to my heart.
Software Distribution. If the class is compiled into the client program directly in the form of code distribution, it will not only occupy unnecessary space, but also cause a lot of updates.
Big difficulty. Because if the class is changed or an error is found, you need to re-compile the client program.
// I have read that com is indeed a good thing. Forgive me for not learning it earlier.
Can the above problems be solved by using DLL?
Using DLL can partially solve the above problem. However, the problem with DLL is that the DLL generated by different compilers may not work together,
"Not enough to create 'vendor-Independent Component soft '"
// COM is distributed in binary format, so there is no compatibility problem between components of different vendors.
Encapsulation of C ++ (another problem with DLL ). The C ++ compilation model requires the customer's compiler to be able to access
All information to create an instance. Assume that the client program uses a DLL and defines a class in the DLL.
, The compiler gets the size of the class defined in the DLL and allocates memory for it (the size of the allocated memory space is fixed during the program running), such
If we have a new version of DLL, the class in this DLL is modified, and the class size is changed. After distribution, if you still use the client program compiled previously
When you call this DLL, an error occurs because the memory allocated by the program cannot meet the requirements.
Handle class: A class represents an interface and a class represents an implementation. Save the implemented handle in the interface class. In this way, the interface and implementation are separated.
Does not affect the existing system. It can partially solve Compiler/connector compatibility issues.
Virtual functions of the interface class are always indirectly called by the function pointer stored in vtbl. The customer program does not need to link the symbols of these functions during development.
Name. The only entry function that needs to be explicitly linked by name is createfaststring. This global function is derived from exern "C", avoiding the symbol name.
Conflict of adaptation methods.
Runtime polymorphism
Object scalability. No interface Deformation
Create COM, from code reuse, to DLL, to interface implementation separation, to virtual function interface implementation.
// Understand why we need Com for Binary-level code reuse. Why is com so popular? Because of its encapsulation, interfaces are separated. I will not talk about many advantages.
I learned it for the first time, read it, browse it, and then study it again.
This is to record the learning process and sort it out after all the learning is completed.