Đa hình (khoa học máy tính)
Trong ngôn ngữ lập trình và lý thuyết kiểu, đa hình (tiếng Anh: polymorphism, từ tiếng Hy Lạp πολύς, polys, "nhiều" và μορφή, morphē, "hình dạng") là việc cung cấp một giao diện cho các thực thể thuộc nhiều kiểu khác nhau.[1] Một kiểu đa hình là kiểu mà những toán tử của nó có thể được áp dụng cho các giá trị của kiểu khác, hoặc các kiểu.[2] Có nhiều loại đa hình cơ bản, gồm: đa hình tùy biến (ad hoc polymorphism), đa hình tham số (parametric polymorphism) và đa hình dẫn xuất (subtyping, hay còn gọi là subtype polymorphism, inclusion polymorphism).
Lịch sử
Các loại đa hình
Đa hình tùy biến
Đa hình tham số
Dẫn xuất
Polytypism
Hiện thực
Xem thêm
- Duck typing for polymorphism without (static) types
- Polymorphic code (Computer virus terminology)
- System F for a phép tính lambda with parametric polymorphism.
- Type class
- Lý thuyết kiểu
- Virtual inheritance
Tham khảo
- ^ Bjarne Stroustrup (ngày 19 tháng 2 năm 2007). “Bjarne Stroustrup's C++ Glossary”.
polymorphism – providing a single interface to entities of different types.
- ^ Cardelli, Luca; Wegner, Peter (tháng 12 năm 1985). “On understanding types, data abstraction, and polymorphism” (PDF). ACM Computing Surveys. New York, NY, USA: ACM. 17 (4): 471–523. doi:10.1145/6041.6042. ISSN 0360-0300.: "Polymorphic types are types whose operations are applicable to values of more than one type."
Liên kết ngoài
- C++ examples of polymorphism
- Objects and Polymorphism (Visual Prolog) Lưu trữ 2009-08-01 tại Wayback Machine