"C ++ Primer" Reading Notes 1 - Chapter 10 Function Template

xiaoxiao2021-03-06  113

Function Template

Strong type language seems to be an obstacle for a relatively simple function to achieve relatively simple functions. For example, the algorithm for the following function min () is simple, but strong type language requires us to implement an instance for all the types of comparisons:

INT min (int A, int b) {

RETURN A

}

Double min (double A, double b) {

RETURN A

Type min (Type A, Type B) {RETURN A

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

New Post(0)