Y
Yuan Ze
The compiler can not compile the code boxing/unboxing value types declared
in a MG C++ class. It reports compiler error 2248, 'member' : cannot
access member declared in class 'class'. To use a "private" value type in a
MG C++ class, I have to make it public. Can anyone tell me if VS2005 has
fixed this problem? Thanks.
Here is the code for testing:
namespace testing
{
__value struct OuterB
{
public:
int i;
};
public __gc class A
{
private:
__value struct InnerB
{
public:
int i;
};
public:
__value struct InnerPublicB
{
public:
int i;
};
public:
void Test()
{
//inner private:error C2248
InnerB innerB;
__box InnerB* pObject=__box(innerB);
InnerB unboxedObject=*__try_cast<__box InnerB*>(pObject);
//error C2248
__box InnerB* pObject2;
InnerB unboxedObject2=*__try_cast<__box InnerB*>(pObject2);
//error C2248
//inner public:OK
InnerPublicB innerPublicB;
__box InnerPublicB* pinnerPublicB=__box(innerPublicB);
InnerPublicB unboxedinnerPublicB=*__try_cast<__box
InnerPublicB*>(pinnerPublicB);
//outer:OK
OuterB outerB;
__box OuterB* pOuterB=__box(outerB);
OuterB unboxedouterB=*__try_cast<__box OuterB*>(pOuterB);
}//A::Test
};//class A
}//namespace testing
in a MG C++ class. It reports compiler error 2248, 'member' : cannot
access member declared in class 'class'. To use a "private" value type in a
MG C++ class, I have to make it public. Can anyone tell me if VS2005 has
fixed this problem? Thanks.
Here is the code for testing:
namespace testing
{
__value struct OuterB
{
public:
int i;
};
public __gc class A
{
private:
__value struct InnerB
{
public:
int i;
};
public:
__value struct InnerPublicB
{
public:
int i;
};
public:
void Test()
{
//inner private:error C2248
InnerB innerB;
__box InnerB* pObject=__box(innerB);
InnerB unboxedObject=*__try_cast<__box InnerB*>(pObject);
//error C2248
__box InnerB* pObject2;
InnerB unboxedObject2=*__try_cast<__box InnerB*>(pObject2);
//error C2248
//inner public:OK
InnerPublicB innerPublicB;
__box InnerPublicB* pinnerPublicB=__box(innerPublicB);
InnerPublicB unboxedinnerPublicB=*__try_cast<__box
InnerPublicB*>(pinnerPublicB);
//outer:OK
OuterB outerB;
__box OuterB* pOuterB=__box(outerB);
OuterB unboxedouterB=*__try_cast<__box OuterB*>(pOuterB);
}//A::Test
};//class A
}//namespace testing