Modify, edit or change a structure
Hello,
i try to find a answear if it is possible to change a defined structure, later maybe to add a new element to the struct?
Is it possible?
of course you can edit a structure just as you can edit any code
Structures and Classes are defined at compile time, not at run-time.
It is you as the coder, that looks at the code text and decides to "modify, edit or change" it.
It is not something that is done during the code execution or run-time.
Structures and Classes are defined at compile time, not at run-time.
It is you as the coder, that looks at the code text and decides to "modify, edit or change" it.
It is not something that is done during the code execution or run-time.
Hi,
i'm a little bit confused about the two answears, let me make a smal example.
struct struct_ar { string fieldname; // Name of the field, also for headline int value_int; // Value of field, integer double value_double; // Value of field, double string value_string; // Value of field, string }; struct_ar myarray[1]; start=0; void OnTick() { if(start==0) { //let me use the origin structure myarray[0].fieldname="abc"; start++; } else { //Now i want to add a new element to the structure myarray[0].newfield="abc"; //This is not possible and failed because the field "newfield" isnt in my structure. //Ist it possible to add a new element in a structure wich is defined in global scope? } }
| There is no “newfield” in the structure. Your code will not compile. You must add it and recompile. | struct struct_ar { string fieldname; // Name of the field, also for headline int value_int; // Value of field, integer double value_double; // Value of field, double string value_string; // Value of field, string }; |
i try to find a answear if it is possible to change a defined structure, later maybe to add a new element to the struct?
Is it possible?