* How to access parent class/object?
@ 2005-03-25 6:57 Adrian Hoe
2005-03-25 7:48 ` Dmitry A. Kazakov
` (2 more replies)
0 siblings, 3 replies; 5+ messages in thread
From: Adrian Hoe @ 2005-03-25 6:57 UTC (permalink / raw)
Hi,
I have the following codes (abbreviated):
package A is
type A_Object is tagged private;
...
end A;
package B is
type B_Object is new A_Object with private;
...
end B;
package C is
type C_Object is new B_Object with private;
...
end C;
package D is
type D_Object is new C_Object with private;
...
end D;
Now, I have the following declaration:
My_D_Object is D.D_Object;
How can I reference the parent objects?
procedure Process_C (C_Obj : access C_Object);
procedure Process_D (D_Obj : access D_Object);
How can I pass C_Object and D_Object into Process_C and Process_D
respectively given only My_D_Object is D.D_Object?
Thanks.
--
Adrian Hoe
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: How to access parent class/object?
2005-03-25 6:57 How to access parent class/object? Adrian Hoe
@ 2005-03-25 7:48 ` Dmitry A. Kazakov
2005-03-25 8:10 ` Adrian Hoe
2005-03-25 8:08 ` Adrian Hoe
2005-03-25 8:08 ` Adrian Hoe
2 siblings, 1 reply; 5+ messages in thread
From: Dmitry A. Kazakov @ 2005-03-25 7:48 UTC (permalink / raw)
On 24 Mar 2005 22:57:10 -0800, Adrian Hoe wrote:
> Hi,
>
> I have the following codes (abbreviated):
>
> package A is
> type A_Object is tagged private;
> ...
> end A;
>
> package B is
> type B_Object is new A_Object with private;
> ...
> end B;
>
> package C is
> type C_Object is new B_Object with private;
> ...
> end C;
>
> package D is
> type D_Object is new C_Object with private;
> ...
> end D;
>
> Now, I have the following declaration:
>
> My_D_Object is D.D_Object;
>
> How can I reference the parent objects?
>
> procedure Process_C (C_Obj : access C_Object);
> procedure Process_D (D_Obj : access D_Object);
>
> How can I pass C_Object and D_Object into Process_C and Process_D
> respectively given only My_D_Object is D.D_Object?
My_D_Object : aliased D_Object := ...;
Process_C (C_Object (My_D_Object)'Access);
Process_D (My_D_Object'Access);
--
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: How to access parent class/object?
2005-03-25 6:57 How to access parent class/object? Adrian Hoe
2005-03-25 7:48 ` Dmitry A. Kazakov
@ 2005-03-25 8:08 ` Adrian Hoe
2005-03-25 8:08 ` Adrian Hoe
2 siblings, 0 replies; 5+ messages in thread
From: Adrian Hoe @ 2005-03-25 8:08 UTC (permalink / raw)
Hi,
Sorry for polluting the bandwidth. I posted this thread without
thinking hard enough. Stupid me! :-)
For the benefits of newbies:
I use class wide type to over this problem.
package A is
type A_Object is tagged private;
type A_Object_Access is access all A_Object'Class;
...
end A;
package B is
type B_Object is new A_Object with private;
type B_Object_Access is access all B_Object'Class;
...
end B;
package C is
type C_Object is new B_Object with private;
type C_Object_Access is access all C_Object'Class;
...
end C;
package D is
type D_Object is new C_Object with private;
type D_Object_Access is access all D_Object'Class;
...
end D;
With the declaration:
My_D_Object : D.D_Object_Access;
Now, call the procedure with:
Process_C (C_Object_Access (My_D_Object));
This should solve the problem.
Cheers,
--
Adrian Hoe
Adrian Hoe wrote:
> Hi,
>
> I have the following codes (abbreviated):
>
> package A is
> type A_Object is tagged private;
> ...
> end A;
>
> package B is
> type B_Object is new A_Object with private;
> ...
> end B;
>
> package C is
> type C_Object is new B_Object with private;
> ...
> end C;
>
> package D is
> type D_Object is new C_Object with private;
> ...
> end D;
>
> Now, I have the following declaration:
>
> My_D_Object is D.D_Object;
>
> How can I reference the parent objects?
>
> procedure Process_C (C_Obj : access C_Object);
> procedure Process_D (D_Obj : access D_Object);
>
> How can I pass C_Object and D_Object into Process_C and Process_D
> respectively given only My_D_Object is D.D_Object?
>
> Thanks.
> --
> Adrian Hoe
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: How to access parent class/object?
2005-03-25 6:57 How to access parent class/object? Adrian Hoe
2005-03-25 7:48 ` Dmitry A. Kazakov
2005-03-25 8:08 ` Adrian Hoe
@ 2005-03-25 8:08 ` Adrian Hoe
2 siblings, 0 replies; 5+ messages in thread
From: Adrian Hoe @ 2005-03-25 8:08 UTC (permalink / raw)
Hi,
Sorry for polluting the bandwidth. I posted this thread without
thinking hard enough. Stupid me! :-)
For the benefits of newbies:
I use class wide type to over this problem.
package A is
type A_Object is tagged private;
type A_Object_Access is access all A_Object'Class;
...
end A;
package B is
type B_Object is new A_Object with private;
type B_Object_Access is access all B_Object'Class;
...
end B;
package C is
type C_Object is new B_Object with private;
type C_Object_Access is access all C_Object'Class;
...
end C;
package D is
type D_Object is new C_Object with private;
type D_Object_Access is access all D_Object'Class;
...
end D;
With the declaration:
My_D_Object : D.D_Object_Access;
Now, call the procedure with:
Process_C (C_Object_Access (My_D_Object));
This should solve the problem.
Cheers,
--
Adrian Hoe
Adrian Hoe wrote:
> Hi,
>
> I have the following codes (abbreviated):
>
> package A is
> type A_Object is tagged private;
> ...
> end A;
>
> package B is
> type B_Object is new A_Object with private;
> ...
> end B;
>
> package C is
> type C_Object is new B_Object with private;
> ...
> end C;
>
> package D is
> type D_Object is new C_Object with private;
> ...
> end D;
>
> Now, I have the following declaration:
>
> My_D_Object is D.D_Object;
>
> How can I reference the parent objects?
>
> procedure Process_C (C_Obj : access C_Object);
> procedure Process_D (D_Obj : access D_Object);
>
> How can I pass C_Object and D_Object into Process_C and Process_D
> respectively given only My_D_Object is D.D_Object?
>
> Thanks.
> --
> Adrian Hoe
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: How to access parent class/object?
2005-03-25 7:48 ` Dmitry A. Kazakov
@ 2005-03-25 8:10 ` Adrian Hoe
0 siblings, 0 replies; 5+ messages in thread
From: Adrian Hoe @ 2005-03-25 8:10 UTC (permalink / raw)
Thanks Dmitry. I have just posted the solution.
I did not think hard enough. Sorry, anyway thanks again.
Cheers,
--
Adrian Hoe
Dmitry A. Kazakov wrote:
> On 24 Mar 2005 22:57:10 -0800, Adrian Hoe wrote:
>
> > Hi,
> >
> > I have the following codes (abbreviated):
> >
> > package A is
> > type A_Object is tagged private;
> > ...
> > end A;
> >
> > package B is
> > type B_Object is new A_Object with private;
> > ...
> > end B;
> >
> > package C is
> > type C_Object is new B_Object with private;
> > ...
> > end C;
> >
> > package D is
> > type D_Object is new C_Object with private;
> > ...
> > end D;
> >
> > Now, I have the following declaration:
> >
> > My_D_Object is D.D_Object;
> >
> > How can I reference the parent objects?
> >
> > procedure Process_C (C_Obj : access C_Object);
> > procedure Process_D (D_Obj : access D_Object);
> >
> > How can I pass C_Object and D_Object into Process_C and Process_D
> > respectively given only My_D_Object is D.D_Object?
>
> My_D_Object : aliased D_Object := ...;
>
> Process_C (C_Object (My_D_Object)'Access);
> Process_D (My_D_Object'Access);
>
> --
> Regards,
> Dmitry A. Kazakov
> http://www.dmitry-kazakov.de
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2005-03-25 8:10 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-03-25 6:57 How to access parent class/object? Adrian Hoe
2005-03-25 7:48 ` Dmitry A. Kazakov
2005-03-25 8:10 ` Adrian Hoe
2005-03-25 8:08 ` Adrian Hoe
2005-03-25 8:08 ` Adrian Hoe
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox