[cairo] forward declaration

Jonathon Jongsma jonathon at quotidian.org
Fri Apr 24 07:08:34 PDT 2009


陈凯 wrote:
> Hi, everyone.  I've got a problem on forward declaration.  In my 
> drawinghelper.h, i wrote my code like this but compilation fails.  g++ 
> complains "Cairo not declared".
> 
> ////////////////////////////  DrawingHelp.h  
> ///////////////////////////////////
> class Context;
> 
> template <typename T>
> class RefPtr;
> 
> class DrawingHelper
> {
> public:
>     void Draw(Cairo::RefPtr<Cairo::Context>& context);  // g++ complains 
> "Cairo not declared".
> 
> // bla bla bla
> };
> 
> //////////////////////////////////////////////////////////////////////////////////////
> 
> Is there anything wrong with that? Please help me to correct my error, 
> thanks :)
> 
> Best regards

This is a general C++ error, not directly related to cairo / cairomm.  If you want to 
forward-declare a namespaced variable, you need to forward-declare it in the namespace as 
well, e.g.:

namespace Cairo {
class Context;
}

-- 
jonner


More information about the cairo mailing list