| | |
Question about structs in managed C++
Please support our C++ advertiser: Intel Parallel Studio Home
![]() |
•
•
Join Date: Jun 2006
Posts: 3
Reputation:
Solved Threads: 0
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:
Will this work?
Thank you already for any replies
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:
C++ Syntax (Toggle Plain Text)
// 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);
Thank you already for any replies
•
•
Join Date: Jun 2006
Posts: 3
Reputation:
Solved Threads: 0
•
•
•
•
Originally Posted by WolfPack
Why don't you try and see?
![]() |
Similar Threads
- question about returnin structs, w/ a bug.. (C++)
- How do i flush a variable (C)
- Question about putting structs into arrays (C++)
Other Threads in the C++ Forum
- Previous Thread: divide
- Next Thread: who can help me in c++ project
| Thread Tools | Search this Thread |
api array arrays based beginner binary bitmap c++ c/c++ calculator char char* class classes coding compile compiler console conversion convert count data database delete desktop developer directshow dll dynamiccharacterarray email encryption error file forms fstream function functions game generator getline google graph homeworkhelper iamthwee ifstream input int integer java lib linkedlist linux list loop looping loops map math matrix memory multiple news node number numbertoword output parameter pointer problem program programming project proxy python random read recursion recursive reference return rpg sorting string strings struct template templates text tree unix url vector video visualstudio win32 windows winsock word wordfrequency wxwidgets






