Advertisement

DX7 game engine & trouble with classes

Started by November 06, 2000 08:26 AM
1 comment, last by Knarkles 24 years, 2 months ago
I have a DirectX surface wrapper class called creatively "Surface", that also handles the locking and drawing to the surface. The class is inherited by "Renderer" and "Image" classes, which represent drawing to a window and a normal image that is usually blitted to a Renderer surface, respectively. Is there any overhead when I call eg. the Circle() function of the Renderer class, when it''s implemented in the Surface class? The drawing functions are not virtual. Another related problem: I have a class called "Base", which is inherited by most of my engine''s classes. It has variables called called "m_Initialized" (self-explanatory) and "m_Name" (used in error messages), and Error() and Log() functions. The Image class is multiply inherited from Resource and Surface classes, which are both inherited from the Base class. Is there any way to ignore the duplicate members of the two inherited Base classes? Or does anyone have a better solution? Here''s an ugly ASCII chart:

    /-> Resource >-\
Base                Image
    \-> Surface  >-/
-Jussi
What you want is called "virtual inheriance". It might look something like this (can''t recall the exact syntax off the top of my head):

    class base{// stuff};class Resource : virtual public base{// stuff};class Surface : virtual public base{// stuff};class Image : public Resource, publc Surface{// stuff};    


You should check this with an official source (like the compiler docs), but now you know what to look for
- Rick
Advertisement
quote: Original post by marvinm

What you want is called "virtual inheriance". It might look something like this (can''t recall the exact syntax off the top of my head):


Ah, yes, thank you, of course, stupid me. I''ve used virtual inheritance before, still I didn''t remember it.

-Jussi

This topic is closed to new replies.

Advertisement