> class Engine {
> public:
[quoted text clipped - 3 lines]
> Form^ dlg; //ERROR C3265
> };
The solution is to use the gcroot template, which is a wrapper around a
low level GC handle:
class Engine {
public:
//...
private:
gcroot<Form^> dlg;
};
Note that gcroot requires manual deletion, it's like an unprotected
pointer that can leak:
Engine::~Engine() { delete dlg; }
Therefore I recommend that you use auto_gcroot, which is a smart pointer
around gcroot, then you don't have to worry about manual deletion:
private:
auto_gcroot<Form^> dlg;
You have to #include <msclr\auto_gcroot.h> in order to use this class.
Tom
Ivan Vecerina - 29 Jun 2006 02:12 GMT
: > class Engine {
: > public:
[quoted text clipped - 3 lines]
: > Form^ dlg; //ERROR C3265
: > };
...
: private:
: auto_gcroot<Form^> dlg;
:
: You have to #include <msclr\auto_gcroot.h> in order to use this class.
Cool. Googling for auto_gcroot brought other useful references.
http://weblogs.asp.net/kennykerr/archive/2005/07/12/419102.aspx
Thank you !
Ivan