Jump to content
Sign in to follow this  
seba1976

Problem with inheritance of sub classes.

Recommended Posts

What would be the right way to do this:

	class SoldierGB;
	class I_G_Soldier_base_F : SoldierGB {
		class EventHandlers : EventHandlers {
			init = "";
		};
	};

The game shows an undefined class "EventHandlers" error message, and refuses to run. I've had the same problem with similar sub classes that are defined within the parent class, but it's definition is not carried over to the new class scope. Like here:

	class NVGoggles;
        class NVGoggles_INDEP : NVGoggles {
        class ItemInfo : ItemInfo {
            uniformModel = "A3\weapons_f\binocular\nvg_proxy_OPFOR.p3d";
            modelOff = "A3\weapons_f\binocular\NVG_proxy_off_OPFOR.p3d";
        };

Even when ItemInfo class is defined in NVGoggles, the parser stops with an undefined class when used within the child class NVGoggles_INDEP, and I have no clue how to make it available inside the new class. Seems more a parser problem than a real one, but I certainly don't know enough.

 

Share this post


Link to post
Share on other sites

IIRC you have to first call the parent subclass from inside the class call to which it belongs.

	class soldierGB {
		class EventHandlers;
	};

	class I_G_Soldier_base_F : SoldierGB {
		class EventHandlers : EventHandlers {
                        init = "";
                };
	};

Share this post


Link to post
Share on other sites
	class NVGoggles {
		class ItemInfo;
	};
        class NVGoggles_INDEP : NVGoggles {
        class ItemInfo : ItemInfo {
            uniformModel = "A3\weapons_f\binocular\nvg_proxy_OPFOR.p3d";
            modelOff = "A3\weapons_f\binocular\NVG_proxy_off_OPFOR.p3d";
        };

Almost did it, but then when previewing a unit:

 

ywz5etR.jpg

Share this post


Link to post
Share on other sites

Well, you are missing a }; at the end there but maybe that's just a copy& paste error.

 

Thinking about it, you may also need the parent class for the class that contains the subclass you want to access too:

	class Binocular;

	class NVGoggles : Binocular {
		class ItemInfo;
	};

	class NVGoggles_INDEP : NVGoggles {
		class ItemInfo : ItemInfo {
			uniformModel = "A3\weapons_f\binocular\nvg_proxy_OPFOR.p3d";
			modelOff = "A3\weapons_f\binocular\NVG_proxy_off_OPFOR.p3d";
		};
	};
  • Like 1

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×