Archived

This topic is now archived and is closed to further replies.

factory with inheritence

This topic is 5129 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I have a factroy but it doesnt work with inheritence. So does any one have any solutions to this problem? I was thinking of making a descriptor class which inherits from the register template and then creates a static instance of the class there fore registering a class with out the class having to inherit from the register template?

Share this post


Link to post
Share on other sites
quote:
I have a factroy but it doesnt work with inheritence.


Uh huh.

quote:
So does any one have any solutions to this problem?



What''s the problem?

Read up on design patterns and especially the part where they give implementation considerations. Factories are easy to inherit from, but from what you want to do, it''s called an Abstract Factory. But before you go off doing what you wanna do, read the motivation for using a Factory and Abstract Factory.

Perhaps you should provide more details, otherwise nobody could help you.

Share this post


Link to post
Share on other sites
what i need is for classes to be registered so i can create instances only using an ID that works with inheritence

cant really get any more detailed than that :-/

Share this post


Link to post
Share on other sites
I tried that once, and although it''s nice and all. It''s just very unwieldly. Adding new interfaces require changing the main interface manager (or whatever you have in mind).

All in all, it''s just not worth the effort, because in the end you''d have to allow prorammers to use the interface and then include the correct header for that to work. Which defeats the purpose of using an ID based system. It simply won''t work.

Share this post


Link to post
Share on other sites
or you could just use component design. so each class contains a structure which describes its interface. (read: MS COM)

I think the guys that wrote CrystalSpace had a good explanation of the mechanisms.

Share this post


Link to post
Share on other sites