24 Apr
2005
24 Apr
'05
7:14 p.m.
On Sun, 24 Apr 2005 14:46:22 -0400, Stephen Torri wrote
...snip...
Each item expect a distinctive input type. If it receives something that it does not know how to handle or need I want to throw an error.
In order to do this I would like to do something like:
void process (Base* sobj) { if (! (isExpectedType(sobj)) { throw NotForMeException (); }
Brake_Pedal* bp = dynamic_cast
(sobj); bp.set_pressure (50); } So perhaps my design is flawed that I am running into this situation.
I'd say so. You might want to read about the Liskov Substitution Principle: http://www.objectmentor.com/resources/articles/lsp.pdf Jeff