Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / Managed C++ / May 2004

Tip: Looking for answers? Try searching our database.

Bug in compiler:Cannot box/unbox private structures declared in a MG C++ class

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Yuan Ze - 14 May 2004 04:42 GMT
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
David Lowndes - 14 May 2004 15:59 GMT
>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?

It doesn't appear to be any different. It gives this error:

error C2248: 'testing::A::InnerB' : cannot access private struct
declared in class 'testing::A'

Dave

Rate this thread:







Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.