Why can't tracking links be used as members of a class?

The following code:

ref class A
{
private:
  int% referenceToAnInt;
};

causes the following error in Visual Studio:

error C3160: 'int%': the data member of the managed class cannot have this type

I thought tracking links were a managed thing, so why can't they be members of a managed class? Also: How did I correctly save the value type reference in C ++ / CLI?

+3
source share
2 answers

The CLR does not allow tracking links to be stored as fields. Also from C ++ / CLI-Spec:

A program containing a tracking link that has a storage duration other than automatic is poorly formed. (This eliminates the ability to track the link as a data item.)

, , , , . reflex reflex /.

+4

- " ", . ++ &, - . ( a.k.a.). , , , , , .

, .Net.

+2

All Articles