Casting
| Appendix A. The RefPtr smartpointer |

## Casting

You can cast RefPtrs to base types, just like normal pointers.

    Glib::RefPtr<Gtk::TreeStore> refStore = Gtk::TreeStore::create(columns);
    Glib::RefPtr<Gtk::TreeModel> refModel = refStore;

This means that any method which takes a `const Glib::RefPtr<BaseType>` argument can also take a `const Glib::RefPtr<DerivedType>`. The cast is implicit, just as it would be for a normal pointer.

You can also cast to a derived type, but the syntax is a little different than with a normal pointer.

    Glib::RefPtr<Gtk::TreeStore> refStore =
    Glib::RefPtr<Gtk::TreeStore>::cast_dynamic(refModel);
    Glib::RefPtr<Gtk::TreeStore> refStore2 =
    Glib::RefPtr<Gtk::TreeStore>::cast_static(refModel);

Dereferencing |  | Checking for null