By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,169 Members | 1,417 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,169 IT Pros & Developers. It's quick & easy.

passing by ref to C++

P: n/a
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
May 17 '06 #1
Share this Question
Share on Google+
3 Replies


P: n/a
Mike,

Can you show the declaration in C++?
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"kiewicz" <ki*****@discussions.microsoft.com> wrote in message
news:90**********************************@microsof t.com...
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

May 17 '06 #2

P: n/a
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]
- mv*@spam.guard.caspershouse.com

"kiewicz" <ki*****@discussions.microsoft.com> wrote in message
news:90**********************************@microsof t.com...
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


May 17 '06 #3

P: n/a
int* p1 when using MC++ (VS2003)
int% p1 when using C++/CLI (VS2005)

Willy.

"kiewicz" <ki*****@discussions.microsoft.com> wrote in message
news:EB**********************************@microsof t.com...
| 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]
| > - mv*@spam.guard.caspershouse.com
| >
| > "kiewicz" <ki*****@discussions.microsoft.com> wrote in message
| > news:90**********************************@microsof t.com...
| > > 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
| >
| >
| >
May 17 '06 #4

This discussion thread is closed

Replies have been disabled for this discussion.