473,385 Members | 1,798 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Overriding a method containing a ref parameter in C++

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?
Nov 17 '05 #1
2 1148
Ed,
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?


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

--
Tomas Restrepo
to****@mvps.org
Nov 17 '05 #2
"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
Nov 17 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Ali Eghtebas | last post by:
Hi, I have 3 questions regarding the code below: 1) Why can't I trap the KEYDOWN while I can trap KEYUP? 2) Is it correct that I use Return True within the IF-Statement? (I've already read...
3
by: Frank Wisniewski | last post by:
Is this suppose to work like this: I have a class called foo in which I tried to override equals and return different answers based on what was passed in. public class foo { private string...
4
by: TS | last post by:
i have a class that i'm trying to understand that overrides BaseApplicationException's methods as follows. What i dont' understand is that i have never seen the inherit ":" on a method signature,...
4
by: Phill. W | last post by:
Here's a knotty little problem. I have some nasty little controls that needs to behave in a non- windows-Standard way - don't ask why; it's a large application being converted from some older...
6
by: John Cobb | last post by:
MSDN and intellisense shows the Add method of Hashtable being overridable however when I use this code: Public Class RAL Inherits Hashtable Public Overrides Sub Add(ByVal Key As String, ByVal...
18
by: JohnR | last post by:
From reading the documentation, this should be a relatively easy thing. I have an arraylist of custom class instances which I want to search with an"indexof" where I'm passing an instance if the...
5
by: Thomas Lorenz | last post by:
Hi I have a class Person and a class Student which inherits from Person. Each class should have a method which copies the properties from another Person or Student respectively. The copy-method...
10
by: r035198x | last post by:
The Object class has five non final methods namely equals, hashCode, toString, clone, and finalize. These were designed to be overridden according to specific general contracts. Other classes that...
1
by: madman228 | last post by:
Hi guys I have run in to a littl bit of trouble. I am writing a class called polynomial in which i need a derivative method I have everything, just dont know how to start the derivative method. Any...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.