Jump to content
  • Advertisement
Sign in to follow this  
Dospro

Making an implementation form an abstrac class

This topic is 4339 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

OK. I have a strange problem, well, its really a question. I Have an abstract class(this means, some virtual routines). Ok. Just tell me if this is posible to do and if i am doing it the correct way. This base abstract class is the main interface for a multi-API implementation. What i try to do is to derive(or how is it say?) a class from the abstract one, which will implement then be implemented with an specific API. This is the idea, but don't know how to do it. Something i got is this: class base { protected: int data; public: virtual void routine(void)=0; }; class dx_base { void routine(void){data=123;}; }; This is more or less the structure i have. The goal here is the with some preprocesor instructions i can decide which derived class to use(dx, ogl, sdl, allegro, etc);

Share this post


Link to post
Share on other sites
Advertisement
thats pretty close to what you would need to do. The only thing your missing in the derived class is to specify the dx_base class is derived of base.

class dx_base : public base
{
void routine(void){ata=123;} // note you don't need a ; after a function declaration that has a body but it doesn't hurt either.
};

Share this post


Link to post
Share on other sites
You might want to take a look at "Striving for Graphics API Independence":
Part 1
Part 2
Part 3
Part 4

The articles make heavy use of D3DX utility functions, which is strange for an article on API independence, but the intent was to show how it is done, not show how to write a math library.

At any rate, you should get some useful information from the articles.

Share this post


Link to post
Share on other sites
Jejeje. I make a little mistake while posting.
Yeah it was actually class dx_base : public base

The articles are excelent. Thank you

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!