I have an abstract base class defined in an MC++ class library. I then
create a descendent class in a C# class library. This seems to work OK with
the exception of one of the abstract member functions/pure virtual function
that uses a passed in pointer to a long.
Just using pointers in the C# library results in the expected: Pointers and
fixed size buffers may only be used in an unsafe context. And using the
'ref' keyword doesn't provide the correct function: no suitable method found
to override.
Any help would be greatly appreciated.
Thanks.
Bill 4 3406
Bill Spahn wrote:
Just using pointers in the C# library results in the expected: Pointers and
fixed size buffers may only be used in an unsafe context.
Take a look at IntPtr. It was designed to store unmanaged pointers and
handles in a managed environment, even with languages that can't handle
pointer syntax at all. http://msdn2.microsoft.com/en-us/lib...em.intptr.aspx
You can use IntPtr to store a pointer's value, but if you actually want
to dereference that pointer, that automatically makes your assembly
unsafe. In C#, you can only use pointer syntax in unsafe context.
Tom
My descendent class overrides an abstract function that needs to modify a
32bit int within the function. In C#, I would just pass in the value as ref
or out. In MC++ I would just pass in a pointer. But since the abstract
class is defined in an MC++ class library and the descenedent class is
defined in a C# class library, I am having a problem finding a parameter
declaration that works for both.
"Tamas Demjen" wrote:
Bill Spahn wrote:
Just using pointers in the C# library results in the expected: Pointers and
fixed size buffers may only be used in an unsafe context.
Take a look at IntPtr. It was designed to store unmanaged pointers and
handles in a managed environment, even with languages that can't handle
pointer syntax at all.
http://msdn2.microsoft.com/en-us/lib...em.intptr.aspx
You can use IntPtr to store a pointer's value, but if you actually want
to dereference that pointer, that automatically makes your assembly
unsafe. In C#, you can only use pointer syntax in unsafe context.
Tom
tivofan wrote:
My descendent class overrides an abstract function that needs to modify a
32bit int within the function. In C#, I would just pass in the value as ref
or out. In MC++ I would just pass in a pointer. But since the abstract
class is defined in an MC++ class library and the descenedent class is
defined in a C# class library, I am having a problem finding a parameter
declaration that works for both.
If you are talking about the old VS 2003 Managed C++ syntax, here's how
to do it: http://www.thescripts.com/forum/thread281243.html
In VS 2005 (C++/CLI), there is such a thing as a managed reference: http://tinyurl.com/3axp9r
Either way, C++ provides a syntax that's compatible with ref and out
parameters in C#.
Tom
OK, I see now that I needed to use a tracking reference '%' instead of the
pointer reference.
Thanks very much for your help.
Bill
"Tamas Demjen" wrote:
tivofan wrote:
My descendent class overrides an abstract function that needs to modify a
32bit int within the function. In C#, I would just pass in the value as ref
or out. In MC++ I would just pass in a pointer. But since the abstract
class is defined in an MC++ class library and the descenedent class is
defined in a C# class library, I am having a problem finding a parameter
declaration that works for both.
If you are talking about the old VS 2003 Managed C++ syntax, here's how
to do it: http://www.thescripts.com/forum/thread281243.html
In VS 2005 (C++/CLI), there is such a thing as a managed reference: http://tinyurl.com/3axp9r
Either way, C++ provides a syntax that's compatible with ref and out
parameters in C#.
Tom This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Tee |
last post by:
Hi,
I have a base usercontrol with a method (blank method, no code), I have
another few usercontrols that will inherit this base usercontrol, but I want
to force all the usercontrol that inheriting this base usercontrol to
override the method with its own code. How do I do it?
I have tried to make the base usercontrol an abstract class (mustinherits +
mustoverrides), this works, but all the usercontrols that inherit it will
not able...
|
by: Dave Veeneman |
last post by:
Is is legal to declare abstract members in non-abstract classes? How about
non-abstract members in abstract classes?
I am writing a base class with three derived classes. The base class will
define the behavior for most, but not all of its members. The derived
classes will define the behavior for the remaining members (the undefined
members).
I'd like to force the derived classes to implement the undefined members in
the base class. I...
|
by: Dan Sikorsky |
last post by:
If we were to define all abstract methods in an abstract class, thereby
making that class non-abstract, and then override the heretofore 'abstract'
methods in a derived class, wouldn't that remove the need to have abstract
class types in C#?
Derived classes from abstract base classes must overrided the abstract
method defininition anyway, so why not just provide a complete definition
for the abstract method when defining the containing...
|
by: Edward Diener |
last post by:
Since a C++ using declaration isn't allowed in MC++, is there a way to
specify that a property, method, event, or field's access can be changed in
a derived class, ie. is protected in one class and is made public in a
derived class ?
|
by: Pohihihi |
last post by:
How can I overload abstract type method in child class?
e.g.
public abstract void BaseMethod()
{
// do something
}
// in child class
| |
by: baibaichen |
last post by:
i have written some code to verify how to disable slicing copy
according C++ Gotchas item 30
the follow is my class hierarchy, and note that B is abstract class!!
class B
{
public:
explicit B(INT32 i =0):i_(i){}
virtual ~B(){}
|
by: emin.shopper |
last post by:
I had a need recently to check if my subclasses properly implemented
the desired interface and wished that I could use something like an
abstract base class in python. After reading up on metaclass magic, I
wrote the following module. It is mainly useful as a light weight tool
to help programmers catch mistakes at definition time (e.g., forgetting
to implement a method required by the given interface). This is handy
when unit tests or...
|
by: Sanders Kaufman |
last post by:
I'm wondering if I'm doing this right, as far as using another class
object as a PHP class property.
class my_baseclass {
var $Database;
var $ErrorMessage;
var $TableName;
var $RecordSet;
function my_baseclass(){
$this->TableName = "";
|
by: Tony |
last post by:
Hello!
If I have an interface Ia and Ib in this way
interface Ia : Ib
Here we say that interface Ia implements interface Ib
If I have a base class called Base and a derived class called Derived we
have
class Derived : Base
Here we say that the Derived class inherit the Base class
|
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |