473,394 Members | 1,810 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

passing by ref to C++

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
3 6294
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

15
by: Dave | last post by:
I'm currently working on a small project (admitedly for my CS class) that compares the time difference between passing by value and passing by reference. I'm passing an array of 50000 int's. ...
58
by: jr | last post by:
Sorry for this very dumb question, but I've clearly got a long way to go! Can someone please help me pass an array into a function. Here's a starting point. void TheMainFunc() { // Body of...
9
by: Just Me | last post by:
PARAFORMAT2 is a structure that SendMessage will return stuff in. Is the "ref" correct or since only a pointer is being passed should it be by value? Suppose I was passing data rather then...
8
by: Dennis Myrén | last post by:
I have these tiny classes, implementing an interface through which their method Render ( CosWriter writer ) ; is called. Given a specific context, there are potentially a lot of such objects,...
22
by: Arne | last post by:
How do I pass a dataset to a webservices? I need to submit a shoppingcart from a pocket PC to a webservice. What is the right datatype? II have tried dataset as a datatype, but I can't get it to...
6
by: MSDNAndi | last post by:
Hi, I get the following warning: "Possibly incorrect assignment to local 'oLockObject' which is the argument to a using or lock statement. The Dispose call or unlocking will happen on the...
12
by: Andrew Bullock | last post by:
Hi, I have two classes, A and B, B takes an A as an argument in its constructor: A a1 = new A(); B b = new B(a1);
12
by: Mike | last post by:
Consider the following code: """ struct person { char *name; int age; }; typedef struct person* StructType;
7
by: TS | last post by:
I was under the assumption that if you pass an object as a param to a method and inside that method this object is changed, the object will stay changed when returned from the method because the...
4
by: Deckarep | last post by:
Hello fellow C# programmers, This question is more about general practice and convention so here goes: I got into a discussion with a co-worker who insisted that as a general practice all...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
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,...
0
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...
0
jinu1996
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...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.