Re: creating a vector of a vector of Gtk::ToggleButton



Paul Davis wrote:

<snip>

	
	typedef std::vector<Gtk::ToggleButton*> chiprow;
	std::vector<chiprow*> _chips;

your mileage may vary as to whether you consider a ToggleButton to
have "weight". note that this approach also means that vector::clear()
(and container::clear() in general) does *not* free the objects
pointed to, which can be problematic sometimes.

--p



I'm glad you mentioned that. I was wondering about the cost of pointer vs local object. Just looking at your example though would I really need to define _chips as a vector to pointers or would this work as well:

typedef std::vector<Gtk::ToggleButton *> chiprow;
std::vector<chiprow> _chips;

That may compile but would it be better to use pointers in the 2nd vector as well?

Thanks for all the help guys.  I'm glad I asked this question.




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]