patrix87 15 Posted February 3, 2016 Hi Is it possible to do Multiple inheritance ? I know you can't do like in C++ and just put a comma to make a single class inherit from multiple classes. But would that work in arma 3; Addon A : Class New_Awesome_Class: Arma3_Base_ClassAddon B : *(this one requires addon A) Class New_Awesome_Class : Another_Class_from_a_mod The Idea is that I do not want the Arma 3 Base class or the Other Class from the other mod to inherit from each other. But I still need my new class to inherit from Both. How can I do that? Thanks Share this post Link to post Share on other sites
Jackal326 1182 Posted February 3, 2016 All you'll do is either create errors (due to duplicate 'New_Awesome_Class' class name) or create a replacement file that will overwrite the initial classname. This is how unit/weapon replacement addons function - they still use existing classnames but change models and/or textures to new ones. Share this post Link to post Share on other sites
patrix87 15 Posted February 3, 2016 I understand that my example is not working. Here's a Simplified Example CfgWeapons { class 556_Magazine { magazines[] = {"30rnd_556x45_EPR","30rnd_556x45_SOST"}; }; class add_special_pointer class WeaponSlotsInfo class PointerSlot: PointerSlot { compatibleItems[] += {"special_pointer"}; }; }; }; class modB_weapon_m4a1: modA_weapon_m4a1,556_Magazine{}; class modB_weapon_m16a4: modA_weapon_m16a4,556_Magazine,add_special_pointer{}; }; In this example I would create a new class using the base class from another mod and a new class I created to overwrite the magazines used by those weapons and also a second new class used to add the ability to use a special pointer for the m16a4. The current way to do that is to rewrite the magazine property and the pointer property in every new class. Which would work but if we have the same 20 properties to change in every weapon then it becomes a bit clumsy and complicated to maintain. Isn't it the base of programming to never write the same code twice ? Share this post Link to post Share on other sites
patrix87 15 Posted February 3, 2016 Feature request submitted here : http://feedback.arma3.com/view.php?id=27732 Share this post Link to post Share on other sites
da12thMonkey 1943 Posted February 3, 2016 Just write a macro set if you don't want to have to constantly write the same parameters: Make a .hpp with some macros e.g weapon_macros.hpp #define _556_MAGAZINES_ magazines[] = {"30rnd_556x45_EPR","30rnd_556x45_SOST"} #define _add_special_pointer_ \ class WeaponSlotsInfo {\ class PointerSlot: PointerSlot{\ compatibleItems[] += {"special_pointer"};\ };\ } Then include them in your config.cpp via the PreProcessor: #include "weapon_macros.hpp" class cfgWeapons{ class modB_weapon_m4a1: modA_weapon_m4a1{ _556_MAGAZINES_; }; class modB_weapon_m16a4: modA_weapon_m16a4{ _556_MAGAZINES_; _add_special_pointer_; }; }; https://community.bistudio.com/wiki/PreProcessor_Commands 2 Share this post Link to post Share on other sites
patrix87 15 Posted February 3, 2016 Just write a macro set if you don't want to have to constantly write the same parameters: Make a .hpp with some macros e.g weapon_macros.hpp #define _556_MAGAZINES_ magazines[] = {"30rnd_556x45_EPR","30rnd_556x45_SOST"} #define _add_special_pointer_ \ class WeaponSlotsInfo {\ class PointerSlot: PointerSlot{\ compatibleItems[] += {"special_pointer"};\ };\ } Then include them in your config.cpp via the PreProcessor: #include "weapon_macros.hpp" class cfgWeapons{ class modB_weapon_m4a1: modA_weapon_m4a1{ _556_MAGAZINES_; }; class modB_weapon_m16a4: modA_weapon_m16a4{ _556_MAGAZINES_; _add_special_pointer_; }; }; https://community.bistudio.com/wiki/PreProcessor_Commands Very interesting, I did not though about that. Thanks Share this post Link to post Share on other sites
patrix87 15 Posted February 7, 2016 Well, after working with that for a couple of days I still maintain that Multiple Inheritance should be a thing. Because I think that the Current Inheritance structure is unnecessarily complex to work with for a simple reason. Every-time you want to redefine something on more than one level at the time you have to re-declare the whole tree of parent classes making sure not to mention one class twice... Which makes it especially hard to do pragmatically or even manually if you have a lot of classes to redefine. Since then they all at some point inherit from each other on multiple level and even sometime on the same level. Multiple Inheritance would solve. Being able to redefine inherited sub-properties without being forced to re-declare them would also solve that issue. Share this post Link to post Share on other sites
patrix87 15 Posted February 7, 2016 Oh and by the way, Bjarne Stroustrup implemented Mulitple Inheritance in C++ in 1984, So I guess that 30 years later Bohemia is probably able to do the same... Share this post Link to post Share on other sites
Jackal326 1182 Posted February 7, 2016 Oh and by the way, Bjarne Stroustrup implemented Mulitple Inheritance in C++ in 1984, So I guess that 30 years later Bohemia is probably able to do the same... Able...yes. Willing is another matter though. Share this post Link to post Share on other sites
patrix87 15 Posted February 7, 2016 After a day I was able to finally write a piece of code than will output all the required inheritance for a large list of classes to be modified. If someone is interested PM me thanks Share this post Link to post Share on other sites