TAILIEUCHUNG - Symbian OS ExplainedEffective C++ Programming for Smartphones phần 9

Mặc dù không ghi trong C + + tiêu chuẩn, trình tự, trong đó chức năng thành viên ảo được quy định trong định nghĩa lớp có thể được giả định là yếu tố duy nhất ảnh hưởng đến thứ tự mà chúng xuất hiện trong bảng chức năng ảo. Bạn không nên thay đổi thứ tự này, | PREVENTING COMPATIBILITY BREAKS 285 Do Not Re-Order Virtual Functions Although not stated in the C standard the order in which virtual member functions are specified in the class definition can be assumed to be the only factor which affects the order in which they appear in the virtual function table. You should not change this order since client code compiled against an earlier version of the virtual function table will call what has become a completely different virtual function. Do Not Override a Virtual Function that was Previously Inherited If you override a virtual function which was previously inherited you are altering the virtual function table of the class. However existing client code is compiled against the original vtable and will thus continue to access the inherited base-class function rather than the new overridden version. This leads to inconsistency between callers compiled against the original version of the library and those compiled against the new version. Although it does not strictly result in incompatibility this is best avoided. For example a client of CSiamese version calling SleepL invokes CCat SleepL while clients of version invoke CSiamese SleepL class CCat public CBase Abstract base class public IMPORT_C virtual CCat 0 public IMPORT_C virtual void PlayL Default implementation IMPORT_C virtual void SleepL Default implementation protected CCat class CSiamese public CCat Version public IMPORT_C virtual --CSiamese public Overrides PlayL but defaults to CCat SleepL IMPORT_C virtual void PlayL . class CSiamese public CCat Version public IMPORT_C virtual --CSiamese public Now overrides PlayL and SleepL IMPORT_C virtual void PlayL IMPORT_C virtual void SleepL . 286 COMPATIBILITY Do Not Modify the Documented Semantics of an API If you change the documented behavior of a class or global function or the meaning of a constant you may break compatibility with previously published versions used by client code regardless of whether .

TAILIEUCHUNG - Chia sẻ tài liệu không giới hạn
Địa chỉ : 444 Hoang Hoa Tham, Hanoi, Viet Nam
Website : tailieuchung.com
Email : tailieuchung20@gmail.com
Tailieuchung.com là thư viện tài liệu trực tuyến, nơi chia sẽ trao đổi hàng triệu tài liệu như luận văn đồ án, sách, giáo trình, đề thi.
Chúng tôi không chịu trách nhiệm liên quan đến các vấn đề bản quyền nội dung tài liệu được thành viên tự nguyện đăng tải lên, nếu phát hiện thấy tài liệu xấu hoặc tài liệu có bản quyền xin hãy email cho chúng tôi.
Đã phát hiện trình chặn quảng cáo AdBlock
Trang web này phụ thuộc vào doanh thu từ số lần hiển thị quảng cáo để tồn tại. Vui lòng tắt trình chặn quảng cáo của bạn hoặc tạm dừng tính năng chặn quảng cáo cho trang web này.