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++ / November 2004

Tip: Looking for answers? Try searching our database.

Overriding a method containing a ref parameter in C++

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Ed Brey - 12 Nov 2004 23:08 GMT
I have a method in a C# assembly like this:

public virtual void RefMeth(ref bool hi) {}

And I want to override it with a VS.Net 2003 Managed C++ method like this:

void RefMeth(bool __gc& hi)

However, when I run, the override never happens.  Moreover, if I explicitly
put the virtual keyword on the C++ declaration for RefMeth, and look at the
generated IL, I see that the method has the newslot bit turned on.

I'm guessing that the compiler is getting confused due to the modopt that is
being applied to the C++ method signature.

What do I do to make the override work?
Tomas Restrepo \(MVP\) - 13 Nov 2004 03:43 GMT
Ed,

> I have a method in a C# assembly like this:
>
[quoted text clipped - 12 lines]
>
> What do I do to make the override work?

Try declaring it in C++ like
void RefMeth(bool __gc* hi);

Signature

Tomas Restrepo
tomasr@mvps.org

Ed Brey - 15 Nov 2004 14:09 GMT
"Tomas Restrepo (MVP)" wrote:

> Try declaring it in C++ like
> void RefMeth(bool __gc* hi);

Thanks.  That dawned on me shortly after I posted (but I couldn't easily
figure out how to get at my posts using MS's web interface to the
newsgroups).  I started out trying a pointer, but forgot about the __gc; then
while seeing if references would worked, I rediscovered the __gc qualifier,
but hadn't put it and the pointer together by the time I thought I should
seek out help.

Thanks for the help!
Ed

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.