Ada 编程/分隔符/*
外观
"*" 运算符定义为所有数值类型的算术乘法。
function"*" (Left, Right : T)returnT;
A :constantFloat := 5.0 * 2.0; -- A is now 10.0 B :constantInteger := 5 * 2; -- B is also 10
withAda.Text_IO;procedureOperator_MultiplyisA :constantFloat := 5.0 * 2.0; -- A is now 10.0 B :constantInteger := 5 * 2; -- B is also 10packageT_IOrenamesAda.Text_IO;packageF_IOisnewAda.Text_IO.Float_IO (Float);packageI_IOisnewAda.Text_IO.Integer_IO (Integer);beginT_IO.Put ("A = "); F_IO.Put ( Item => A, Fore => 3, Aft => 1, Exp => 0); T_IO.New_Line; T_IO.Put ("B = "); I_IO.Put ( Item => B, Width => 3, Base => 10); T_IO.New_Line;endOperator_Multiply;
创建一个字符串,其中单个字符被复制 n 次。
function"*" (Left : Natural; Right : Character)returnString;
除了标准字符串之外,此 运算符 也为 Bounded_String 和 Unbounded_String 定义。
A : constant String := 10 * 'X'; -- A is filled with 10 X
字符复制 运算符 是 Ada.Strings.Fixed 包 的一部分。您需要with 和use 该包来使 运算符 可见。
withAda.Text_IO;withAda.Strings.Fixed;procedureOperator_Multiply_2isuseAda.Strings.Fixed; A :constantString := 10 * 'X'; -- A is filled with 10 XpackageT_IOrenamesAda.Text_IO;beginT_IO.Put_Line ("A = " & A);endOperator_Multiply_2;
创建一个字符串,其中源字符串被复制 n 次。
function"*" (Left : Natural; Right : String)returnString;
除了标准固定字符串之外,此 运算符 也为 Bounded_String 和 Unbounded_String 定义。
A : constant String := 3 * "Hello "; -- A is filled with 3 Hello
字符串复制 运算符 是 Ada.Strings.Fixed 包 的一部分。您需要with 和use 该包来使运算符可见。
withAda.Text_IO;withAda.Strings.Fixed;procedureOperator_Multiply_3isuseAda.Strings.Fixed; A :constantString := 3 * "Hello "; -- A is filled with 3 Hello.packageT_IOrenamesAda.Text_IO;beginT_IO.Put_Line ("A = " & A);endOperator_Multiply_3;
- 4.4 表达式 (注释)
- 4.5.5 乘法运算符 (注释)
- A.4.3 固定长度字符串处理 (注释)
- A.4.4 有界长度字符串处理 (注释)
- A.4.5 无界长度字符串处理 (注释)
- 4.4 表达式 (注释)
- 4.5.5 乘法运算符 (注释)
- A.4.3 固定长度字符串处理 (注释)
- A.4.4 有界长度字符串处理 (注释)
- A.4.5 无界长度字符串处理 (注释)
| Ada 运算符 | ||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
