rtti & virtual

Is there a way to avoid this ugly rtti?
integer dimension needed in make().

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
class Relation
{
   void make() { ..... ; if (dimensions() == 2) .... ; ..... }
   virtual int dimensions() = 0;
};

class Relation1D : public Relation
{
   virtual int dimensions() { return 1; }
};

class Relation2D : public Relation
{
   virtual int dimensions() { return 2; }
};

.........
Last edited on
I don't know what you mean. Do you want to get rid of the virtual functions? In that case why not store dimensions a member variable that you set to whatever you want it to be?
Can you give more details about what you need Relation to do? Just from what you've posted, there doesn't seem to be any need for inheritance at all, here.
Ooops...
Yeah you right.
What I am thinking?
Topic archived. No new replies allowed.