Making an implementation form an abstrac class

Started by
2 comments, last by Dospro 17 years, 9 months ago
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);
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.};
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.
Jejeje. I make a little mistake while posting.
Yeah it was actually class dx_base : public base

The articles are excelent. Thank you

This topic is closed to new replies.

Advertisement