zoukankan      html  css  js  c++  java
  • From MSDN: Pointers in the Common Type System


    Pointers are special kinds of variables. There are three kinds of pointers supported by the runtime: managed pointers, unmanaged pointers, and unmanaged function pointers.

    A managed pointer, also known as a handle to an object on the managed heap, is a new type of pointer available to managed applications. Managed pointers are references to a managed block of memory from the common language runtime heap. Automatic garbage collection is performed on this heap. Managed pointers are generated for method arguments that are passed by reference. Some languages provide other ways of generating managed pointers. Only managed pointers are CLS-compliant.

    Note:

    In Visual C++ 2002 and Visual C++ 2003, __gc * was used to declare a managed pointer. This is replaced with a ^ in Visual C++ 2005, for example ArrayList^ al = gcnew ArrayList();.

    An unmanaged pointer is the traditional C++ pointer to an unmanaged block of memory from the standard C++ heap. Because unmanaged pointers are not part of the Common Language Specification (CLS), your language might not provide syntax to define or access these types. See the documentation for your language for information on support for unmanaged pointers.

    An unmanaged function pointer is also a traditional C++ pointer that refers to the address of a function. The CLS provides delegates as a managed alternative to unmanaged function pointers.

    An explicit definition of a pointer type is not required. All the information necessary to determine the type of a pointer is present when the pointer is declared.

    While pointer types are reference types, the value of a pointer type is not an object and you cannot determine the exact type from such a value.

    The common type system provides two type-safe operations on pointer types: loading a value from and writing a value to the location referenced by the pointer. These type-safe operations are CLS-compliant.

    The common type system also provides three byte-based address arithmetic operations on pointer types: adding integers to and subtracting integers from pointers, and subtracting one pointer from another. The results of the first two arithmetic operations return a value of the same type as the original pointer. These byte-based operations are not CLS-compliant.

  • 相关阅读:
    Rstudio代码的快捷键
    sqlhelper帮助类
    图片上传
    反射获取 obj类 的属性 与对应值
    jquery 操作 动态创建的 元素
    Path类使用
    jquery 小数计算保持精度
    js字符串转成数字
    DateTime.Now.ToString()的各种字符串
    Linq语句 动态组建
  • 原文地址:https://www.cnblogs.com/silva/p/1076100.html
Copyright © 2011-2022 走看看