Discover new programming technologies, include the articles, news, trends, analysis and practical advice about new programming technologies on alibabacloud.com
This chapter mainly refers to Sun company documentation.
C + + programmers are certainly not unfamiliar with fan-type programming, especially when the STL is a big line, c#2.0 will also realize the function of paradigm programming. Java is not outdone, but also introduced the paradigm of programming language new f
of some tools. Generics promote code reuse without manual transformation (manual casting), and often manual casting can pose some problems with type security.
The other four modifications were: Use a For loop to traverse the container (Collection type) without requiring an explicit declaration of the container's iterator (iterator); Enumeration types provide enhanced type security beyond the final static int; Provides automatic boxing (autoboxing) functionality when using basic data types (pri
that are completely unrelated to it.The fourth method, usingcombination (composition)The way.Public class ImprovedlistThe improvedlist adds an extra layer of locking through its own built-in lock. It does not care whether the underlying list is thread-safe, and even if the list is not thread-safe or modifies its yoke, improved provides a consistent locking mechanism for thread safety. Although the additional synchronization layer can cause slight performance loss, improvedlist is more robust t
the virtual function table of Class A, and if the PA points to an object of Class B, the address is the address of the virtual function table of Class B.(2) Find the virtual function table based on the address of the virtual function table, and find the address of the virtual function to be called. It may be considered that the virtual function table is looked up with the function name as an index, although there is a more efficient way to find it. If the PA points to an object of Class A, it w
The member functions of the class can be called each other. Statements that call other virtual member functions in addition to member functions (except static member functions, constructors, and destructors) are polymorphic. For example:#include Output:CDERIVER::FUNC2 ()Line 20th calls the FUNC1 member function. Enter the FUNC1 member function, execute to line 8th, and call the FUNC2 function. It looks like the FUNC2 member function of the CBase class should be called, but the output proves that
Calling a virtual function in a constructor and destructor is not polymorphic, because at compile time you can determine which function is called. If this class has the function, the call is the function of this class, if this class does not, call the function of the direct base class, if the base class does not, call is the function of the indirect base class, and so on. For example:#include Output resultsB::helloa::bye Calling virtual functions in constructors and destructors------
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.