Click here to Skip to main content
15,888,454 members
Please Sign up or sign in to vote.
2.00/5 (1 vote)
See more:
static string helper(Device dev)
{
XmlSerializer xmlser=new XmlSerializer(dev.GetType());
}


Here Device is a class holding multiple strings.I want to send the same thing in c++.
I tried the below code. It showing error.
static string helper(Device dev)
{
XmlSerializer^ xmlser=gcnew XmlSerializer(dev->GetType());
}


I used Device& and Device *dev. But it dint work. please give me an idea
Posted
Updated 11-Feb-14 18:59pm
v2
Comments
Sergey Alexandrovich Kryukov 12-Feb-14 0:55am    
This is not really C++, this is C++/CLI. Please tag "C++/CLI", to avoid confusing people reading the list of questions.
—SA
chandanadhikari 12-Feb-14 0:59am    
for moving big objects between functions a reference is the way to go , please check your method declarations...probably something wrong with the syntax....by the way what is the error ??
Sergey Alexandrovich Kryukov 12-Feb-14 1:02am    
Probably?!! :-) Perhaps very probably. :-)
Please read my answer... :-)
—SA

1 solution

The declaration equivalent to C# declaration show would be
C++
static string^ helper(Device^ dev);

However, that, apparently would not be enough for you. You need to learn how .NET references are work in general, and how are they used with C++/CLI. For that purpose, start reading some C++/CLI and .NET manual, pretty much from the very beginning — the format of this forums is not designed to explain it all in one Quick Answer. You should never use trial and error method of writing code. Instead, you should clearly understand the meaning of every line you write. And every character, if this is something like '*', '&', or '^'. :-)

—SA
 
Share this answer
 
Comments
chandanadhikari 12-Feb-14 1:19am    
5! have not worked with C++/CLI so this was totally new learning
~thanks SA
Sergey Alexandrovich Kryukov 12-Feb-14 1:52am    
Thank you very much. Hope OP will learn it. (Not such a bid deal, I would say.)
—SA

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900