Array+=: Difference between revisions
Jump to navigation
Jump to search
Lou Montana (talk | contribs) m (Fix spacing) |
Lou Montana (talk | contribs) (Fix description) |
||
Line 1: | Line 1: | ||
{{GVI|arma3|0.50}} same-file support<!-- in 2011 --><br> | |||
{{GVI|arma3|1.00}} full support<!-- in 2013 --> | |||
The <syntaxhighlight lang="cpp" inline>array[] += {}</syntaxhighlight> syntax allows to add items to an existing array inherited from the direct parent. | |||
{{Feature|important| | |||
* This syntax has limitations in inheritance - see {{Link|#Limitations}}. | |||
* This syntax should '''not''' be used in [[Description.ext]] - only in modded {{Link|Config.cpp/bin File Format|config.cpp}}. | |||
}} | |||
Line 26: | Line 30: | ||
</syntaxhighlight> | </syntaxhighlight> | ||
== Limitations == | |||
Only '''direct inheritance''' of an explicitly-stated array works. The following cases do '''not''' work: | Only '''direct inheritance''' of an explicitly-stated array works. The following cases do '''not''' work: | ||
{ | {| style="awidth: 100%" | ||
| style="width: 50%" | | |||
<syntaxhighlight lang="cpp"> | <syntaxhighlight lang="cpp"> | ||
class A { array[] = { any, thing }; } | class A { array[] = { any, thing }; }; | ||
class B : A {}; | class B : A {}; | ||
class C : B // inherits from B which inherits from A (without changes) | class C : B // inherits from B which inherits from A (without changes) | ||
Line 38: | Line 44: | ||
}; | }; | ||
</syntaxhighlight> | </syntaxhighlight> | ||
| | |||
<syntaxhighlight lang="cpp"> | <syntaxhighlight lang="cpp"> | ||
class A { array[] = { any, thing }; }; | class A { array[] = { any, thing }; }; | ||
Line 47: | Line 53: | ||
}; | }; | ||
</syntaxhighlight> | </syntaxhighlight> | ||
|} | |||
[[Category:BIS File Formats]] | [[Category:BIS File Formats]] | ||
[[Category:Introduced with Arma 3 version 0.50]] | |||
[[Category:Introduced with Arma 3 version 1.00]] |
Latest revision as of 14:41, 13 June 2023
0.50 same-file support
1.00 full support
The array[] += {}
syntax allows to add items to an existing array inherited from the direct parent.
Usage
class A
{
array[] = { any, thing };
};
class B : A
{
array += { more, Bstuff };
};
class C : A // inherits from A, -not- B
{
array += { other, Cstuff };
};
Limitations
Only direct inheritance of an explicitly-stated array works. The following cases do not work:
class A { array[] = { any, thing }; };
class B : A {};
class C : B // inherits from B which inherits from A (without changes)
{
array[] += { wont, work }; // result: array[] = { wont, work };
};
|
class A { array[] = { any, thing }; };
class B : A { array[] += { more, stuff }; };
class C : B // inherits from B which inherits from A (with += changes)
{
array[] += { wont, work }; // result: array[] = { wont, work };
};
|