When I try to compile functionB in Visual C++ it gives me this error:-Code:class Editor { // c'tors etc Gtk::EventBox canvas_event_box; void functionA(); void functionB() const; } // This is fine void functionA() { const Glib::RefPtr<Gdk::Window> p = canvas_event_box.get_window(); } // But this won't compile void functionB() const { const Glib::RefPtr<Gdk::Window> p = canvas_event_box.get_window(); }
and this is the code from glibmm/refptr.hglibmm/refptr.h(199) : error C2440: 'initializing' : cannot convert from 'const Gdk::Window *' to 'Gdk::Window *'
Conversion loses qualifiers
I don't actually want to change anything in the member variable canvas_event_box. I just want to be able to call one of its functions from my 'const' member function. Is there any syntax I can use to tell VC++ that I'm not actually changing the variable - just using itCode:// The templated ctor allows copy construction from any object that's // castable. Thus, it does downcasts: // base_ref = derived_ref template <class T_CppObject> template <class T_CastFrom> inline RefPtr<T_CppObject>::RefPtr(const RefPtr<T_CastFrom>& src) : // A different RefPtr<> will not allow us access to pCppObject_. We need // to add a get_underlying() for this, but that would encourage incorrect // use, so we use the less well-known operator->() accessor: pCppObject_ (src.operator->()) { if(pCppObject_) pCppObject_->reference(); }![]()


Reply With Quote
Bookmarks