C ++ criticism criticism

xiaoxiao2021-03-06  208

1, TYPEDEF does not need?

A, TYPEDEF provides a layer of indirect, object-oriented language, the interface masks the difference between the different specific types of runtime, and Typedef masks the difference between different types of different types, but does not lose type security B, general language only You can return "value", and Typedef provides the ability to return "type", which is an indispensable mechanism for template programming, unless the template programming is not necessary.

2, import

Inside the # include, private members in different locations in the header file, the inline function is also criticized in the header file. In fact, there is only one: C is not a platform, it does not have a binary standard, it is compiled into a local code, Lost all type information; only solve this problem, can solve various problems related to the import of distribution

3. Is the reference are extra? Will it be destroyed?

A. Resource release problem reference is more clear than the pointer, that is, providing the original object part of the resource, and once the interface parameters are used with pointers, it is necessary to agree to release the resource B, and the empty reference is in the Well-Formed program. Because the only way to generate it is to provide an empty pointer, and the proceedings are undefined behaviors, and the program will be wrong, not like the destroyed pointer, some operations, sometimes, sometimes mistakes, sometimes Not

C99 also joined the support for reference

4, repeat inheritance directly

C lacks the "direct repeated inheritance" mechanism owned by Eiffel, but if any, what is semantic? Didn't read Eiffel, don't understand

5, multiple inheritance

The discussion of more incisive, the inheritance of multiple processing is the soft ribs of C , Java prohibits multiple implementation inheritance, but the "single-realization inheritance multi-interface inheritance internal class" is lacking flexibility and intuitiveness

6, internal class destroying object-oriented object? Destroying reuse?

There is a fair, unless the object-oriented exit is an interface, multiplexed only source code multiplexed; 1, the internal class provides better encapsulation; 2, the internal class can provide an interface-oriented interface after simple packaging. Reuse, an example is "List Collections.unmodifiedList (List)", which can be implemented in internal class (I don't know how actual implementation)

7, Virtual / Override

C and C # practice gave the author of the base class author, and these bobbin authors are borne; including the virtual foundation class in C , the changes of subclasses force the parent class to make changes

8, virtual type

In the text, C only provides parameterization, no virtual type, can be seen from the example of the virtual type, it seems to be completed using the typefef despised by the previous article, and I don't know if it is.

9, binding polyure

In C , it is generally called template parameter constraints. It is considering joining the next version of the criteria; but if you just use the example, the template parameter constraint is to implement an interface, then use the interface as a parameter. Why is it necessary? Wild? The generic expression has a Concept, and the pan-reference should also be Concept Check, not Type Check.

10, access control

EIFFEL pair sub-access rights can only be considered to be a characteristic, not necessarily the advantage; based on two different understandings and focus on multiplexing, C and Eiffel selection two different attitudes; for C private inheritance criticism The example of time is not appropriate, causing the root of the problem to force transformation, not private inheritance 11, expand object

The criticism of "." And "->" is too isolated. In fact, "->" is an overloaded operator, providing a layer of indirect, using this layer indirectly can do a lot of things: resource management, tolerant The convenience of inheritance (automatic "automatic" has a "method of inclusive object), etc .; Eiffel provides" expansion object ", I don't know how the specific semantics

12, repeat inheritance

Topping here, I saw a use of directly inherited in the EIFFEL: It turned out to be a method of adjusting the parent class in the subclass; this usage can also be abandoned with Precursor to join the language.

13, resistance and coordination

Return Value Coordination does not seem to have a big problem, the parameter resistance does not seem to have a big problem, the problem is that the parameter coordination; Eiffel provides Current and Like to solve, C can only expect a bundled Pan.

14, forced interface programming

The author believes that the Publician member in the parent class is changed to protected or private if the subclass is defined, and it will bring the cohabese problem, in fact, as long as the semantics of the function, there is nothing; and this change will bring another effect. : Force for interface programming; because your customer programmer can only reference your sub-class object to a member of a member of the child.

15, garbage collection

Still those topics, or those arguments, or to avoid resource management outside the memory, do not talk about; do you "destructive function stack object heap object garbage collection"? C only default "heap object garbage collection", the smart pointer can also support for a while, Java and Eiffel lack "Stack Object Destructor"

16, contract design with corba id1

The author believes that CORBA IDL does not support contractual design is a defect, but I never dare to use assertions in my DCOM, RMI, .NET Remoting components, including the initial socket server; this is exposed to network environment, violating the front The condition is to be throwing; WebService is slightly, clearly defined abnormal processing, and has middleware support

转载请注明原文地址:https://www.9cbs.com/read-128594.html

New Post(0)