- 论坛徽章:
- 0
|
懂了, 懂了, 我原来以为是A中定义了类B, 然后实例化B b, 这样的设计和b的实例化有关。 因为书中有一段解释, 让人感觉是这样的。
我把书中一段解释再附上:
class A : public Gtk::TreeStore
{
protected:
A()
{
//We can’t just call Gtk::TreeStore(b) in the initializer list
//because b does not exist when the base class constructor runs.
//And we can’t have a static b instance, because that would be
//instantiated before the gtkmm type system.
//So, we use this method, which should only be used just after creation:
set_column_types(b)
}
};
public:
static Glib::RefPtr<A> create()
{
return Glib::RefPtr<A>(new A);
}
class B : Gtk::TreeModel::ColumnRecord
{
};
B b;
};
A a = A::create(); |
[ 本帖最后由 huwenhuo 于 2009-9-25 21:42 编辑 ] |
|