Click to See Complete Forum and Search --> : C2039: namespaces, events and delegates


clavrg
October 11th, 2004, 12:19 PM
Trying compile following snippet yields an error C2039:

namespace M {
public __gc class M {
public:
__delegate void MyDelegate(System::Object * sender);
__event MyDelegate * m;
};
}

error C2039: '__ctor' : is not a member of 'ComPort::ComPort'

The error goes away if I do one of the following:
1) change name of the namespace to a different from class name
2) define a delegate outside of the namespace
3) comment event declaration

Any thoughts on why does it behave that way?

NoHero
October 11th, 2004, 12:23 PM
I think you have to implement a constructor ... Try to implement a constructor for your class ...


namespace M
{
public __gc class M
{
public:

M ( void );
~M ( void );
__delegate void MyDelegate(System::Object * sender);
__event MyDelegate * m;
};

M::M ( void )
{ // constructor
}

M::~M ( void )
{ // destructor

}
}