Can You Have "Empty" Abstract/Classes?

Posted by ShrimpCrackers on Programmers See other posts from Programmers or by ShrimpCrackers
Published on 2011-04-06T07:06:41Z Indexed on 2012/09/09 21:48 UTC
Read the original article Hit count: 395

Filed under:

Of course you can, I'm just wondering if it's rational to design in such a way.

I'm making a breakout clone and was doing some class design. I wanted to use inheritance, even though I don't have to, to apply what I've learned in C++. I was thinking about class design and came up with something like this:

GameObject -> base class (consists of data members like x and y offsets, and a vector of SDL_Surface*

MovableObject : GameObject -> abstract class + derived class of GameObject (one method void move() = 0; )

NonMovableObject : GameObject -> empty class...no methods or data members other than constructor and destructor(at least for now?).

Later I was planning to derive a class from NonMovableObject, like Tileset : NonMovableObject. I was just wondering if "empty" abstract classes or just empty classes are often used...I notice that the way I'm doing this, I'm just creating the class NonMovableObject just for sake of categorization.

I know I'm overthinking things just to make a breakout clone, but my focus is less on the game and more on using inheritance and designing some sort of game framework.

© Programmers or respective owner

Related posts about class-design