解引用

你可以使用->操作符解引用智能指针,就像使用普通指针访问底层实例的方法一样。

auto refPixbuf = Gdk::Pixbuf::create_from_file(filename);
auto width = refPixbuf->get_width();

你还可以使用*操作符和get()方法访问底层实例,不过通常这不是一个好主意。除非你非常的谨慎没有犯错,否则你将得到一个不存在于引用计数中的指向底层实例的指针或底层实例的引用。

auto refPixbuf = Gdk::Pixbuf::create_from_file(filename);
auto& underlying = *refPixbuf; // Possible, but not recommended