Though records can now share much of the functionality of classes, there are some important differences between classes and records.
Records do not support inheritance.
Records can contain variant parts; classes cannot.
Records are value types, so they are copied on assignment, passed by value, and allocated on the stack unless they are declared globally or explicitly allocated using the New and Dispose function. Classes are reference types, so they are not copied on assignment, they are passed by reference, and they are allocated on the heap.
Records allow operator overloading on the Win32 platform; classes, however, do not allow operator overloading.
Records are constructed automatically, using a default no-argument constructor, but classes must be explicitly constructed. Because records have a default no-argument constructor, any user-defined record constructor must have one or more parameters.
Record types cannot have destructors.
Virtual methods (those specified with the virtual, dynamic, and message keywords) cannot be used in record types.
Unlike classes, record types on the Win32 platform cannot implement interfaces.
Partager