G
Guest
Hello,
I'm trying to implement "Null-Field" feature (like Stream::Null) in MC++, but I am not able to initialize static member properly due to compiler error C2512 (no appropriate default constructor available):
public __gc class ObjectCollection : public CollectionBase
{
public:
ObjectCollection() { }
// CollectionBase Methods...
private:
__gc class NullObjectCollection; // Forward declaration
public:
static ObjectCollection *Null = new NullObjectCollection(); // <- Error C2512
};
__gc class ObjectCollection::NullObjectCollection : public ObjectCollection
{
public:
NullObjectCollection() { }
};
I've also tried to replace
static ObjectCollection *Null = new NullObjectCollection();
with
static ObjectCollection *Null;
static ObjectCollection() // Static Constructor
{
Null = new NullObjectCollection(); // <- C2512 Too
}
but with the same error... Any ideas? Is is only possible in C#?
I'm trying to implement "Null-Field" feature (like Stream::Null) in MC++, but I am not able to initialize static member properly due to compiler error C2512 (no appropriate default constructor available):
public __gc class ObjectCollection : public CollectionBase
{
public:
ObjectCollection() { }
// CollectionBase Methods...
private:
__gc class NullObjectCollection; // Forward declaration
public:
static ObjectCollection *Null = new NullObjectCollection(); // <- Error C2512
};
__gc class ObjectCollection::NullObjectCollection : public ObjectCollection
{
public:
NullObjectCollection() { }
};
I've also tried to replace
static ObjectCollection *Null = new NullObjectCollection();
with
static ObjectCollection *Null;
static ObjectCollection() // Static Constructor
{
Null = new NullObjectCollection(); // <- C2512 Too
}
but with the same error... Any ideas? Is is only possible in C#?