comp.lang.ada
 help / color / mirror / Atom feed
* implicit cast and inheritance
@ 2004-10-01 20:50 Rick Santa-Cruz
  2004-10-02  0:09 ` Stephen Leake
  0 siblings, 1 reply; 8+ messages in thread
From: Rick Santa-Cruz @ 2004-10-01 20:50 UTC (permalink / raw)


Hi,

I have a small question. See the following source-code:
package Pack is
    type Base is tagged
        record
            Value: Integer;
        end record;
    procedure Base_Proc(B: Base);

    type Derived is new Base with
        null record;
end Pack;

And now I have the following source for the main-procedure:
with Pack;
use Pack;

procedure main is
    B: Base;
    D: Derived;
    procedure Proc(B: Base) is
    begin
        null;
    end Proc;
begin
    Pack.Base_Proc(B);    -- 1
    Pack.Base_Proc(D);    -- 2
    Proc(B);   -- 3
    Proc(D);    -- 4
end main;

It is clear to me, that the (4) won't compile, but I can solve it in making 
a cast or defining Proc with 'Class. My question is now why I can call 
Base_Proc(D). It is clear to me that the class Derived inherit the 
Base_Proc-Procedure from its base-class, but what is with the parameter? Why 
does this work?
I have a suggestion why this works... cause it is in the same package... but 
how does it internly work? If it is in the same package, is then always 
implicitly done a cast, or is the procedure Base_Proc in the derived class 
"Derived" automatically defined with a parameter Type "Derived"?

Thanks a lot in advance,
Rick 





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

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

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-10-01 20:50 implicit cast and inheritance Rick Santa-Cruz
2004-10-02  0:09 ` Stephen Leake
2004-10-02 16:32   ` Rick Santa-Cruz
2004-10-02 21:35     ` Stephen Leake
2004-10-02 22:05       ` Rick Santa-Cruz
2004-10-03 10:23         ` Marius Amado Alves
2004-10-03 13:27           ` CBFalconer
2004-10-03 12:32         ` Stephen Leake

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