Connections

M

Mark Stijnman

I have a hierarchy of classes that need to be able to be connected to
each other. It consists of an Abstract Base Class, and a set of
descending classes, A, B, C and D. As connections have properties too
(such as the angle between the objects it connects), it will be
modelled as a separate class Connection. I am still deciding whether I
will make Connection templated over the type of objects it connects -
probably I won't. At any rate, I want each object descending of Base to
accept two connections, one incoming at the start, one outgoing at the
end (Connections are oriented, just like the objects they connect).
Unfortunately, not all combinations are valid. Objects of class A
cannot connect to another object of class A, for instance. How would I
implement this neatly? How would I define the virtual methods in Base
to reflect the demand that all descandants of Base should be able to
accept or make connections? How would the methods in the descending
classes be defined, to only make or accept connections in valid
combinations? Any standard design patterns I should look up for this?
Thanks for any tips.

regards Mark
 

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

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,066
Latest member
VytoKetoReviews

Latest Threads

Top