T
thwei
How to translate this to c++
public new Bar this[int nIndex]
{
get{ return (Bar)base[nIndex]; }
}
public new Bar this[int nIndex]
{
get{ return (Bar)base[nIndex]; }
}
thwei said:How to translate this to c++
public new Bar this[int nIndex]
{
get{ return (Bar)base[nIndex]; }
}
Assuming the class that contains that property derives from a class called
Bar.
[System::Reflection:efaultMember(S"Item")]
public __gc class Bar
{
public:
__property Bar* get_Item(int index)
{
return NULL;
}
};
public __gc class Foo : public Bar
{
public:
__property Bar* get_Item(int index)
{
return Bar::get_Item(index);
}
};
__property Bar* get_Item(int nIndex) {
return __try_cast<Bar*>(this->BaseClassName::Item[nIndex]; }
}
In the old syntax, you also need to put this attribute on the containing
__gc class: [System::Reflection:efaultMember(S"Item")]
thwei said:U¿ytkownik "Hasani (remove nospam from address)"
Assuming the class that contains that property derives from a class called
Bar.
[System::Reflection:efaultMember(S"Item")]
public __gc class Bar
{
public:
__property Bar* get_Item(int index)
{
return NULL;
}
};
public __gc class Foo : public Bar
{
public:
__property Bar* get_Item(int index)
{
return Bar::get_Item(index);
}
};
Yes, but this one problem:
public __gc class Bar
{
public:
__property Object* get_Item(int index)
{
return NULL;
}
};
public __gc class Foo : public Bar
{
public:
__property Bar* get_Item(int index) //Error C2392 covariant returns types
are not supported in managed types
{
return Bar::get_Item(index);
}
};
Exactly:
public __gc class Foo : public ArrayList
{
public:
__property Bar* get_Item(int index) //Error C2392 covariant returns types
are not supported in managed types
{
return Bar::get_Item(index);
}
};
thwei said:Type Item of base class is Object and this generated Error C2392
"covariant returns types are not supported in managed types"