Constness
Prev | Appendix A. The RefPtr smartpointer | Next

## Constness

The use of the const keyword in C++ is not always clear. You might not realise that `const Something*` declares a pointer to a const Something, The pointer can be changed, but not the Something that it points to.

Therefore, the RefPtr equivalent of `Something*` for a method parameter is `const Glib::RefPtr<Something>&`, and the equivalent of `const Something*` is `const Glib::RefPtr<const Something>&`.

The `const ... &` around both is just for efficiency, like using `const std::string&` instead of `std::string` for a method parameter to avoid unnecessary copying.

Prev | Up | Next
Checking for null | Home | Appendix B. Signals