- Reference type
In
Object-oriented programming , a reference type is adata type that can only be accessed by references. Unlike objects ofvalue type s, objects of reference types cannot be directly embedded into composite objects and are always dynamically allocated. They are usually destroyed automatically after they become unreachable.Immutable object s are usually of a reference type, where supported.Language and platform support
*
C++ has no built-in support for reference types. However this behavior can be emulated by restricting access to a type's constructor.
* The.NET Framework makes a clear distinction between value and reference types, and allows creation of user-defined types for both kinds.
** In C#, thestruct
keyword defines a value type, while theclass
keyword defines a reference type.
** InC++/CLI , the keyword pairsvalue class
andvalue struct
define managed value types, while theref class
andref struct
pairs define managed reference types.
* On the Java platform, all composite and user-defined types are reference types. Onlyprimitive type s are value types.
* Windows COM objects are reference-counted reference types.
Wikimedia Foundation. 2010.