Re: Searching OO Associations with RDBMS Persistence Models

From: Falk Tannhäuser <>
Date: Tue, 20 Jun 2006 20:21:01 +0200
Message-ID: <e79eac$8lf$>

Robert Martin wrote:
> In C++, 'this' is most definitely not like a field. In C++ an object
> can have more than one pointer value. In the case where D inherits from
> both A and B, the 'this' pointer value will be different depending on
> whether you are calling a method implemented in A, B, or C. Thus, the
> 'this' pointer is not guaranteed to be a unique value. Therefore, even
> though the 'this' pointer has a true value separate from the value of
> the object it points to, it cannot be reliably used as a key into a
> dictionary.

>> And the fact that in
>> C++ an object can have multiple numerical addresses is just
>> an implementation artifact.

> One that has significant implications when thinking about keys.

Just for the record: dynamic_cast<void const*>(this) will yield a "pointer to the most derived object pointed to by 'this'" which can be used as a unique key for the object in question. All you need for the dynamic_cast to work is that 'this' be a pointer to a polymorphic type.

Falk Received on Tue Jun 20 2006 - 20:21:01 CEST

Original text of this message