Hello,
This is my first post here, although I have been browsing these forums for a while now, and I must say this is quite an informative place.
I have a small question that I would like to post, more to verify if I am correct or not in how this should be implemented.
I am working in Visual Studio 2005, and using managed C++ code with /clr. I have a struct definition, wich needs to be returned from a function. Sample code would be as follows:
// This would be the struct definition, at the start of the project.
// It's defined directly in the project namespace, not inside a class:
public ref struct TheStruct
{
int structval1;
int structval2;
};
// This would be a function inside a class (which resides in the same
// namespace as the struct) to return the struct.
// Inside the function, another similarily declared struct is used as
// source to convert it into TheStruct.
TheStruct^ ConvertStruct(SomeOtherStruct s)
{
TheStruct tmp;
tmp.structval1 = s.someval1 / 255;
tmp.structval2 = s.someval2 / 255;
return ^tmp;
}
// finally, the conversion is called in source as:
TheStruct MyWorkStruct = ConvertStruct(MyOtherStruct);
Will this work?
Thank you already for any replies :)