Board index » delphi » Referencing the ancestor

Referencing the ancestor

Hi to all,

I need to send an ancestor as a pointer to an object, my first try was
something like @(inherited self), didn't work (although  @(inherited
<func_x) is correct from the sintax (syntactic?) point of view).

I finally settled for a @local_variable, where local_variable is the
first variable in the ancestor object and therefore the same location in
memory, but I was wondering if there's a more academical way to do it (I
had to declare that variable public).

Greetings.

Leopoldo.

 

Re:Referencing the ancestor


Quote
Leopoldo Salvo Massieu wrote:

> Hi to all,

> I need to send an ancestor as a pointer to an object, my first try was
> something like @(inherited self), didn't work (although  @(inherited
> <func_x) is correct from the sintax (syntactic?) point of view).

> I finally settled for a @local_variable, where local_variable is the
> first variable in the ancestor object and therefore the same location in
> memory, but I was wondering if there's a more academical way to do it (I
> had to declare that variable public).

> Greetings.

> Leopoldo.

ok Leopoldo. The address is simply @self.

Re:Referencing the ancestor


Quote
Leopoldo Salvo Massieu wrote:

> Hi to all,

> I need to send an ancestor as a pointer to an object, my first try was
> something like @(inherited self), didn't work (although  @(inherited
> <func_x) is correct from the sintax (syntactic?) point of view).

> I finally settled for a @local_variable, where local_variable is the
> first variable in the ancestor object and therefore the same location in
> memory, but I was wondering if there's a more academical way to do it (I
> had to declare that variable public).

> Greetings.

> Leopoldo.

This sounds a bit odd!  How can you have a pointer to an ancestor?  An
ancestor is a class and not an object instance and therefore cannot have
 a pointer.  For example you may have an abstract ancestor and a
descendant.  The descendant uses the ancestors attributes and methods
and might override some of them but the ancestor itself does not
exist! The ancestor is never instanciated and therefore no object or
pointer exists!

Maybe you can re-phrase your problem or tell us what you want to
achieve.  All your current solution does is returning a pointer to the
first memory location of the (descendant) object itself.  The fact that
the attribute (variable) it is declared in the ancestor is academic.

Matthias

Other Threads