A set of coding specifications that invoke C # 's auto-encapsulated C # SDK through C # will discover the importance of object-oriented thinking. The C + + SDK can be converted to the C # SDK using the Automatic encapsulation tool. However, the following rules are required: 1. If a C # object needs to be judged, there are three cases (take bmppen as an example): Determine if the C # object itself is equal to bool isequal=object. Equals (BP1,BP2); Determines if C # holds a pointer to C + + objects equal to bool Isequal= (BP1. Nativeobject==bp2. NativeObject); Determines whether the values of C + + objects held by C # objects are equal to bool isequal= (BP1==BP2); 2. About derivation: C # can be derived from C + + auto-encapsulated C # classes C # can override the virtual methods of C + + to allow C # to add non-public methods, non-public properties when C # increases public methods, public properties, you must use the combination of way 3. Life cycle: Who applies, who releases (c + + auto-encapsulated C # SDK objects need to call Dispose () of this object ) 4. Smart pointer: The life cycle of a smart pointer is the same as the object life cycle, and the smart pointer object is just a special object that manages the memory of another object it aggregates by reference counting. It is important to note that when a smart pointer object is destroyed, it simply decrements the reference count, does not necessarily destroy the aggregate object, and only the reference count equals 0 o'clock, the aggregate object is destroyed. After C # calls the smart pointer object, it is important to explicitly release the smart pointer object, otherwise the reference count of the smart pointer object does not decrement, whereas in a C + + program, the smart pointer object is released immediately.
C # downgrade with C + + SDK coding common sense