Ada 程式設計/分隔符/*
外觀
(重定向自 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 運算子 | ||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
