passing by ref to C++

G

Guest

I'm writing a function in managed C++ that takes three integer references as
parameters. Passing 'ref int' from C# does not work. Is there an easy way
to pass by reference from C# to C++?

I saw someone on the web suggest using the percent sign on the C++ side, but
that just got me a syntax error.

Thanks,
Mike
 
G

Guest

Here are some that I've tried unsuccessfully. I changed the function and
variable names to uh....protect the innocent.

void Function(int& p1, int& p2, int& p3);
void Function(Int32& p1, Int32& p2, Int32& p3);
void Function(Int32% p1, Int32% p2, Int32% p3);

Mike


Nicholas Paldino said:
Mike,

Can you show the declaration in C++?


--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

kiewicz said:
I'm writing a function in managed C++ that takes three integer references
as
parameters. Passing 'ref int' from C# does not work. Is there an easy
way
to pass by reference from C# to C++?

I saw someone on the web suggest using the percent sign on the C++ side,
but
that just got me a syntax error.

Thanks,
Mike
 
W

Willy Denoyette [MVP]

int* p1 when using MC++ (VS2003)
int% p1 when using C++/CLI (VS2005)

Willy.

| Here are some that I've tried unsuccessfully. I changed the function and
| variable names to uh....protect the innocent.
|
| void Function(int& p1, int& p2, int& p3);
| void Function(Int32& p1, Int32& p2, Int32& p3);
| void Function(Int32% p1, Int32% p2, Int32% p3);
|
| Mike
|
|
| "Nicholas Paldino [.NET/C# MVP]" wrote:
|
| > Mike,
| >
| > Can you show the declaration in C++?
| >
| >
| > --
| > - Nicholas Paldino [.NET/C# MVP]
| > - (e-mail address removed)
| >
| > | > > I'm writing a function in managed C++ that takes three integer
references
| > > as
| > > parameters. Passing 'ref int' from C# does not work. Is there an
easy
| > > way
| > > to pass by reference from C# to C++?
| > >
| > > I saw someone on the web suggest using the percent sign on the C++
side,
| > > but
| > > that just got me a syntax error.
| > >
| > > Thanks,
| > > Mike
| >
| >
| >
 

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