How to use the c # structure
This article mainly explains "how to use c # structure". Interested friends may wish to have a look at it. The method introduced in this paper is simple, fast and practical. Let's let the editor take you to learn how to use the c # structure.
Look directly at C++ and c # code:
Struct structpointer {int id; int* ptrid;}; void processstructpointer (structpointer * sp) {if (sp = = NULL) return; int* p; p = sp- > ptrid; while (true) {if (* p! = 0) / / process {cout ptrid = p as long as it is not 0 / / notice how to write processstructpointer (pt); processstructpointer (pt);}
Note: the phenomenon of calling processtructpointer (pt) twice in a row:
1) when ids [0] = 1; ids [1] = 5; ids [2] = 0, then all phenomena are normal OK
2) when ids [0] = 1; ids [1] = 5; ids [2] = 7, then all phenomena are incorrect.
The above two phenomena are easy to understand, the key is the structure, structure pointers, structure members are pointers, structure pointers as parameters between C++ and c # how to deal with. In fact, there is also IntPtr that can handle struct-related parameters.
Supplementary note:
In the past, the experiment has always been that the name of struct in C++ and c # is the same. Today, the above structpointer is changed to structpointerxback, and other c # code is changed accordingly. As a result, the experiment is also OK. This shows that the name is just a form, really from the memory point of view, C++ processing is not in terms of the name, or from the physical structure of memory.
At this point, I believe you have a deeper understanding of "how to use the c # structure". You might as well do it in practice. Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!