Storage of C++ Class Hierarchy

I

ik

Hello All,
Please point me to the right news group if this is not the right one.

I have to store c++ class hierarchy, in some structure. From that
structure, I need to query for the baseclasses. I get the base class,
derived class information from a text file of the form

[baseclass1,derivedclass1]
[baseclass1,derivedclass2]
[baseclass2,derivedclass3]
[derivedclass3,derivedclass6] .. etc

This list is a plain one, and has multiple classes, I mean there are
different base classes and its associated derived classes. Multiple
inheritence is also allowed. Fortunately, all the class names are
unique.
I tried diffenent implementaions like maintianing two list, one for the
derived class and another for the inherited class and look the
inherited table to get the base class.. and so I create a structure ..
which I see is not efficient at all. Can somebody recommend a better
way to do this ?

Thanks for any suggestions.
 
K

Kai-Uwe Bux

ik said:
Hello All,
Please point me to the right news group if this is not the right one.

I have to store c++ class hierarchy, in some structure. From that
structure, I need to query for the baseclasses. I get the base class,
derived class information from a text file of the form

[baseclass1,derivedclass1]
[baseclass1,derivedclass2]
[baseclass2,derivedclass3]
[derivedclass3,derivedclass6] .. etc

This list is a plain one, and has multiple classes, I mean there are
different base classes and its associated derived classes. Multiple
inheritence is also allowed. Fortunately, all the class names are
unique.
[snip]

It appears to me that the inheritence data define a directed graph wherein
each class is a vertex and directed edges represent inheritence. What I am
not sure about is the kind of questions you want to ask. For instance, if
you want to know whether a certain class is a (possibly indirect) base
class of some other class, then you would need to decide if there is a
directed path joining two given vertices.

This is a general graph programming problem and not really on-topic is this
group: here we are concerned with the C++ language proper. Neither your use
of C++ for solving the problem nor the origin of your data from a C++ class
hierarchy ensure topicality. You might want to try comp.programming.

This said, you also might want to check out whether the Boost Graph library
(or any other library providing graphs like LEDA) would do better than what
you have so far.


Best

Kai-Uwe Bux
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,176
Messages
2,570,950
Members
47,503
Latest member
supremedee

Latest Threads

Top