[odb-users] Problem with pointer in base class

Boris Kolpackov boris at codesynthesis.com
Wed Jul 3 11:40:36 EDT 2013


Hi John,

Ball, John R <jrball at sandia.gov> writes:

> I tried this with polymorphic inheritance and ended up with large Foo 
> and Bar base tables which might be a problem - I don' t know yet.

With polymorphic inheritance, tables corresponding to Foo and Bar base
classes will only contain data members in these classes while derived
tables will contain additional data members added in derived classes.

With the reuse inheritance each table always contains all the data
members from base to the derived class.

So I don't see how the tables could be bigger with the polymorphism
inheritance. You may end up with fewer tables (if some of the bases
are abstract) in resue inheritance, but not with smaller ones.


> In the meantime, if I go this way, can I still do queries against
> Foo derived or do I have to query against Foo base?

You can query for either. In fact, in polymorphic inheritance, the
object type (base or derived) that you query for becomes part of
the query condition. For example:

db.query<fruit> (query::color == red); // Any red fruit.
db.query<apple> (query::color == red); // Only red apples.

Boris



More information about the odb-users mailing list