main.adb

来自「Ada 2005 Training Notes.」· ADB 代码 · 共 52 行

ADB
52
字号
with Random;with Stacks;with Ada.Text_IO;use Ada.Text_IO;procedure Main is   X: Random.Small;   OS1 : Stacks.Object_Stack ;   OS2 : Stacks.Object_Stack ;   OP: Stacks.Object_Class_Ptr;begin   Random.Init(100);   for I in Random.Small'Range loop      X := Random.Next;      Put_Line("Random Next = " & Random.Small'Image(X));   end loop;   OP := new Stacks.Circle;--   OP.X := 0.0;--   OP.Y := 0.0;--   OP.Radius := 1.1;   Stacks.Push(OS1, OP);   Stacks.Push(OS1, OP);   Stacks.Push(OS1, OP);   --   -- Prefixed notation   -- OS1 type is tagged and type'Class class-wide parameter   --   for I in Integer range 1..99 loop      OS1.Push(OP);      OS2.Push(OP);   end loop;   if OS1."="(OS2) then      Put_Line("OS1 is equal to OS2");   else      Put_Line("OS1 is not equal to OS2");   end if;   if OS2."="(OS2) then      Put_Line("OS2 is equal to OS2");   else      Put_Line("OS2 is not equal to OS2");   end if;end Main;

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?