virtual override

  • Thread starter Thread starter Urs Wigger
  • Start date Start date
U

Urs Wigger

Hi,

In a mangaed C++ wrapper class, I have some pure virtual function
declarations:

public __gc __abstract class CESCSAPICommand
{
......
// Test only
virtual bool Test(int i1, int i2) = 0;

// SendPacket() takes address and size of a byte array buffer:
virtual bool SendPacket(unsigned char packetAddress __nogc[], int
packetSize) = 0;
.....
}

When trying to override these in a C# application, this works fine for a
simple Test() method just using 2 intergers.
However, I have no chance to override SendPacket()!

My relevant C# code looks as follows:

class CESCSMyAPICommand: CESCSAPICommand
{
.....
public override bool Test(int i1, int i2) {...} // compiles
and works fine, but....

public override bool SendPacket(byte [] packetAddress , int
packetSize)
{
.....
socket.Send(packetAddress , 0, packetSize, 0);
.....
}

// ... causes compiler error s:
'ConsoleApplication1.CESCSMyAPICommand' does not implement
inherited abstract
member 'CESCSAPICommand.SendPacket(byte*, int)'

'ConsoleApplication1.CESCSMyAPICommand' .SendPacket(byte[],
int)': no suitable method found to override
....
}

What is wrong? In other words: how do I correclty declare my pure
virtual function SendPacket(bufferAddress,bufferSize) in managed C and
override it in a C# application so that I cann pass the parameters to
Socket:Send() ??

Thanks in advance
Urs

PS: remove leading / trailing ns_, _ns from e-mail address
 
Urs,

I believe that you want something like this:

virtual bool SendPacket(byte packetAddress __gc[], int packetSize) = 0;

The __gc indicates that the array is a managed array.

Hope this helps.
 
Back
Top