RE: [GD-General] Multiple Inheritance and RTTI
Brought to you by:
vexxed72
From: Gareth L. <GL...@cl...> - 2003-02-06 14:02:36
|
> But I asked for a real example (read taken from a real > project) of using > (not implementing) the QI pattern, an example that demonstrates the > superiority of QI over the alternatives. Sorry, missunderstood. What are the alternatives that you want to compare it with ? Internet explorer is an example I guess. > FWIW, for the QI implementation, I prefer a > dynamic_cast-style interface: > > if(IRenderable * p = queryInterface<IRenderable>(q)) > { > // do stuff > } There are pros and cons to that. I prefer returning an error code like HRESULT because the reason for the failure could be important. But it's a matter of taste > (when I feel like reinventing dynamic_cast at all, that is.) COM isn't just a RTTI replacement. I personally use dynamic_cast in some of my projects, but not as a way to build a concrete class out of interfaces. YMMV I guess. |