Re: Two warnings when creating a TreeStore



Murray Cumming wrote:
On Fri, 2007-09-14 at 12:07 -0400, Jos�lburquerque wrote:
Murray Cumming wrote:
On Thu, 2007-09-13 at 11:15 -0400, Jos�lburquerque wrote:
As far as gtkmm and inheritance, I found that if I use something like TreeModelColumn<MyBaseClass> in a TreeModelColumnRecord, derived members of MyBaseClass only use the virtual methods of the base class (not the derived class!), but if I use something like TreeModelColumn<MyBaseClass*>, dereferencing the pointer to the derived class later, does use the virtual (overridden) method of the derived class. Thanks again everyone for your help.
This is just like putting a Derived instance in a std::list<Base>. The
Base part will be copied into a new instance in the list, but that
instance won't be a Derived. This is how copy-by-value works.

I see, this is just standard C++. I'm slightly new to C++ (coming from C and then Java), but I *am* learning as I go along. :-)

Java doesn't really have copy-by-value for non-fundamental types.
Everything is a reference there. The rough equivalent in C++ is to use
smartpointers or regular pointers (plus your own memory management).

That's right. This is probably the most new aspect of C++ to me (I've had to learn about copy constructors, implementing an equal operator for classes, etc). I also should brush up on when objects are copied by value, etc., especially when I'm working with derived classes, etc. (which as you know led me to the misconception I explained above).

I'm not completely alien to C/C++ memory management though. I'm trying to use the class' destructors to manage objects which I "new"; as you say, I'm also using smartpointers where I can and thanks to the excellent "manage()" function, I can leave newly created widgets in control of Gtkmm.

-Jose



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