Array of arrays

  • Thread starter Jonathan DeCarlo
  • Start date
J

Jonathan DeCarlo

I have a situation where I need to override a method in
managed C++ that was originally defined in C#. The
method takes a parameter of an array of arrays of
doubles. Here is a simple examples that shows what I'm
talking about:

///////////////////////////////////////////
// C# Base Class
public class A
{
public abstract void func(double[][] x);
}


// MC++ Derived Class
public __gc class B : public A
{
public:
virtual void func(double x __gc[] __gc[]);
};
////////////////////////////////////////////

The problem is that I get errors when I compile my C++
class even though this is how intellesense tells me the
prototype of the function should look. The only thing
that has gotten me past the syntax errors is to define
the function as follows:

virtual void func(Array* x __gc[]);

However, since the base class method is abstract, I'm
getting an error message that says that my C++ class is
abstract as well because I didn't override func.

My question is, what is the correct syntax for the
function that takes an array of arrays of doubles? In
other words, what's the equivalent of C#'s "double[][]"
type in MC++?

Thanks in advance for any help!

Sincerely,
Jonathan DeCarlo
 
R

Ronald Laeremans [MSFT]

C++ does not support jagged arrays (arrays of arrays) in version 7.0 or 7.1.
There isn't a really feasible workaround if you don't control the API.

You could e.g. write an adaptor in C# that turns the arrays of arrays into a
rectangular array.

Ronald Laeremans
Visual C++ team
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top