[cairo] cairomm: reference counting v. inheritance

Murray Cumming murrayc at murrayc.com
Mon Dec 19 01:50:34 PST 2005


On Sat, 2005-12-17 at 16:54 +0100, Christian Biesinger wrote:
> Murray Cumming wrote:
> > Cairo::LinearGradient derived2 =
> > dynamic_cast<Cairo::LinearGradient>(base); //Not valid syntax.
> 
> What about:
> 
> Cairo::LinearGradient& derived2 =
>      dynamic_cast<Cairo::LinearGradient&>(base);

However, the LinearGradient& is not reference-counted, so bad things
happen if you keep it longer than base.

I suppose that 

Cairo::LinearGradient derived2  =
dynamic_cast<Cairo::LinearGradient&>(base);

could work, though it looks strange.

-- 
Murray Cumming
murrayc at murrayc.com
www.murrayc.com
www.openismus.com



More information about the cairo mailing list