RefPtr and inheritance



Hi there !

I'm wondering the current behavior of refptr since I have some segfault in
my application (and usually, I search for errors in the others' code,
instead of mine :D)

Let's say, we have classes A and B, B inherits A.
I have some Glib::RefPtr instance, pointing to a B instance (obviously ! =))
What I'd like to know is, when I do :
Glib::RefPtr refB = Glib::RefPtr(new B());
Glib::RefPtr  refA = Glib::RefPtr (refB);

How are the counts ?
- RefPtr is based on the "reference" it encapsulates : we have two times the
same reference... so the count is 2
- RefPtr takes in consideration the given template : so we have a count of 1
reference of RefPtr and 1 reference of RefPtr  (which is a bit "problematic"
since when one RefPtr will be destroyed, the other will point on nothing !)

I'd prefer the first solution, even if It would imply that the problem is my
fault somewhere :D

Thanks in advance :)
-- 
View this message in context: http://www.nabble.com/RefPtr-and-inheritance-tf2401125.html#a6695068
Sent from the Gtkmm mailing list archive at Nabble.com.




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