comp.lang.ada
 help / color / mirror / Atom feed
* What is derived?
@ 2004-10-02 16:15 Rick Santa-Cruz
  2004-10-02 21:30 ` Stephen Leake
  0 siblings, 1 reply; 4+ messages in thread
From: Rick Santa-Cruz @ 2004-10-02 16:15 UTC (permalink / raw)


Hi,

is the following list complete:
subprograms of a base-class will be inherited, if:
(1) they are in the same package as the base-type and not in a child-package
(2) they have as parameter or as return type the base-class

That's it, or am I missing something? At least I think, that private-methods 
are inherited, or am I wrong?

Thanks in advance,
Rick 





^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: What is derived?
  2004-10-02 16:15 What is derived? Rick Santa-Cruz
@ 2004-10-02 21:30 ` Stephen Leake
  2004-10-02 22:02   ` Rick Santa-Cruz
  0 siblings, 1 reply; 4+ messages in thread
From: Stephen Leake @ 2004-10-02 21:30 UTC (permalink / raw)
  To: comp.lang.ada

"Rick Santa-Cruz" <rick_santa_cruz75@msn.com> writes:

> Hi,
> 
> is the following list complete:
> subprograms of a base-class will be inherited, if:
> (1) they are in the same package as the base-type and not in a child-package
> (2) they have as parameter or as return type the base-class
> 
> That's it, or am I missing something? 

That's it.

> At least I think, that private-methods are inherited, or am I wrong?

If by "private-methods" you mean "subprograms declared in the private
part of the package spec", then yes and no. They will be derived if
they are visible at the point of derivation. 

-- 
-- Stephe




^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: What is derived?
  2004-10-02 21:30 ` Stephen Leake
@ 2004-10-02 22:02   ` Rick Santa-Cruz
  2004-10-03 16:54     ` Martin Krischik
  0 siblings, 1 reply; 4+ messages in thread
From: Rick Santa-Cruz @ 2004-10-02 22:02 UTC (permalink / raw)


Hi,

thanks for your answer!

>> At least I think, that private-methods are inherited, or am I wrong?
>
> If by "private-methods" you mean "subprograms declared in the private
> part of the package spec", then yes and no. They will be derived if
> they are visible at the point of derivation.
What do you mean with visible at the point of deriviation? For example if a 
procedure is declared after the a type is derived, then is this procedure 
not visible? Are there more special cases?

Thanks in advance,
Rick 





^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: What is derived?
  2004-10-02 22:02   ` Rick Santa-Cruz
@ 2004-10-03 16:54     ` Martin Krischik
  0 siblings, 0 replies; 4+ messages in thread
From: Martin Krischik @ 2004-10-03 16:54 UTC (permalink / raw)


Rick Santa-Cruz wrote:

> Hi,
> 
> thanks for your answer!
> 
>>> At least I think, that private-methods are inherited, or am I wrong?
>>
>> If by "private-methods" you mean "subprograms declared in the private
>> part of the package spec", then yes and no. They will be derived if
>> they are visible at the point of derivation.
> What do you mean with visible at the point of deriviation? For example if
> a procedure is declared after the a type is derived, then is this
> procedure not visible? Are there more special cases?

Remember that private work on child packages and not on child classes.

So a child class which is inside a child packages can see procedures
declared inside private.

A child class declared in an unrelated package can not see the private part
and therefore cannot inherit private procedures.

If you are a C++ convert then I suggest to declare all child classes in
child packages -  that make transition easier for you

With Regards

Martin.

PS: The following creates a class where the outsild world does not know it
is OO. Favourite example is Unbounded_String. Since Unbounded_String may
not leak memory and almost no Ada compiler implements garbage collection it
needs some form of destructor. Therefore Unbounded_String is internally a
class.

package Hidden_Tag

  type Object is private;

private

  type Object is tagged private;

end Hidden_Tag;

-- 
mailto://krischik@users.sourceforge.net
http://www.ada.krischik.com




^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2004-10-03 16:54 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-10-02 16:15 What is derived? Rick Santa-Cruz
2004-10-02 21:30 ` Stephen Leake
2004-10-02 22:02   ` Rick Santa-Cruz
2004-10-03 16:54     ` Martin Krischik

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox