new vs __gc new

  • Thread starter Thread starter Ioannis Vranos
  • Start date Start date
I

Ioannis Vranos

Why the following does not compile:


#using <mscorlib.dll>

int main()
{
int __gc *p= __gc new int;
}



while the following compiles?


#using <mscorlib.dll>

int main()
{
int __gc *p= new int;
}
 
Ioannis said:
Why the following does not compile:


#using <mscorlib.dll>

int main()
{
int __gc *p= __gc new int;
}



while the following compiles?


#using <mscorlib.dll>

int main()
{
int __gc *p= new int;
}



I just checked the web and found that since int is a value type, int
__gc * is an interior pointer (a pointer that points to value types) and
not a managed pointer.


However does this imply that we have to call delete explicitly on this
kind of interior pointers, or the object is cleaned by CLR?
 
Back
Top