Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
|
|
@ -0,0 +1,8 @@
|
|||
package My_Class is
|
||||
type Object is tagged private;
|
||||
procedure Primitive(Self: Object); -- primitive subprogram
|
||||
procedure Dynamic(Self: Object'Class);
|
||||
procedure Static;
|
||||
private
|
||||
type Object is tagged null record;
|
||||
end My_Class;
|
||||
18
Task/Call-an-object-method/Ada/call-an-object-method-2.ada
Normal file
18
Task/Call-an-object-method/Ada/call-an-object-method-2.ada
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
package body My_Class is
|
||||
procedure Primitive(Self: Object) is
|
||||
begin
|
||||
Put_Line("Hello World!");
|
||||
end Primitive;
|
||||
|
||||
procedure Dynamic(Self: Object'Class) is
|
||||
begin
|
||||
Put("Hi there! ... ");
|
||||
Self.Primitive; -- dispatching call: calls different subprograms,
|
||||
-- depending on the type of Self
|
||||
end Dynamic;
|
||||
|
||||
procedure Static is
|
||||
begin
|
||||
Put_Line("Greetings");
|
||||
end Static;
|
||||
end My_Class;
|
||||
11
Task/Call-an-object-method/Ada/call-an-object-method-3.ada
Normal file
11
Task/Call-an-object-method/Ada/call-an-object-method-3.ada
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
package Other_Class is
|
||||
type Object is new My_Class.Object with null record;
|
||||
overriding procedure Primitive(Self: Object);
|
||||
end Other_Class;
|
||||
|
||||
package body Other_Class is
|
||||
procedure Primitive(Self: Object) is
|
||||
begin
|
||||
Put_Line("Hello Universe!");
|
||||
end Primitive;
|
||||
end Other_Class;
|
||||
20
Task/Call-an-object-method/Ada/call-an-object-method-4.ada
Normal file
20
Task/Call-an-object-method/Ada/call-an-object-method-4.ada
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
with Ada.Text_IO; use Ada.Text_IO;
|
||||
|
||||
procedure Call_Method is
|
||||
|
||||
package My_Class is ... -- see above
|
||||
package body My_Class is ... -- see above
|
||||
|
||||
package Other_Class is ... -- see above
|
||||
package body Other_Class is ... -- see above
|
||||
|
||||
Ob1: My_Class.Object; -- our "root" type
|
||||
Ob2: Other_Class.Object; -- a type derived from the "root" type
|
||||
|
||||
begin
|
||||
My_Class.Static;
|
||||
Ob1.Primitive;
|
||||
Ob2.Primitive;
|
||||
Ob1.Dynamic;
|
||||
Ob2.Dynamic;
|
||||
end Call_Method;
|
||||
Loading…
Add table
Add a link
Reference in a new issue