I got stuck with a "ref" keyword which is applied to the class in .cpp file. I want to access a method which is marked as __clrcall. Can u tell me what ref keyword used for in visual c++ code?
我遇到了一个“ref”关键字,该关键字应用于.cpp文件中的类。我想访问标记为__clrcall的方法。你能告诉我visual c ++代码中使用的ref关键字是什么吗?
2 个解决方案
#1
The "short short" version is that a "ref class" is a managed class. You can't have member variables of a managed type (.NET Library objects, like StringBuilder or TCPListener) in a class that is not declared "ref" -- that is, unmanaged classes cannot contain managed objects.
“简短”版本是“ref class”是托管类。您不能在未声明为“ref”的类中拥有托管类型的成员变量(.NET库对象,如StringBuilder或TCPListener) - 也就是说,非托管类不能包含托管对象。
#2
From MSDN:
A ref class or ref struct can inherit from zero or more managed interfaces and zero or one ref types. A value class or value struct can only inherit from zero or more managed interfaces.
ref类或ref结构可以从零个或多个托管接口以及零个或一个ref类型继承。值类或值结构只能从零个或多个托管接口继承。
#1
The "short short" version is that a "ref class" is a managed class. You can't have member variables of a managed type (.NET Library objects, like StringBuilder or TCPListener) in a class that is not declared "ref" -- that is, unmanaged classes cannot contain managed objects.
“简短”版本是“ref class”是托管类。您不能在未声明为“ref”的类中拥有托管类型的成员变量(.NET库对象,如StringBuilder或TCPListener) - 也就是说,非托管类不能包含托管对象。
#2
From MSDN:
A ref class or ref struct can inherit from zero or more managed interfaces and zero or one ref types. A value class or value struct can only inherit from zero or more managed interfaces.
ref类或ref结构可以从零个或多个托管接口以及零个或一个ref类型继承。值类或值结构只能从零个或多个托管接口继承。