国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 學院 > 開發設計 > 正文

ChucK初步(8)

2019-11-14 08:45:37
字體:
來源:轉載
供稿:網友

functions

writingcallingoverloading

writing(書寫)

keyWord fun (or function) followed by the return type and then the name of the function. After the name of the function parentheses(括號) must be opened to declare the types of the input arguments.

// define function call 'funk' fun void funk( int arg ) { // insert code here } // define function 'addOne' fun int addOne(int x) { // result return x + 1; }

calling(調用)

// define 'hey' fun int hey( int a, int b ) { // do something return a + b; } // call the function; store result hey( 1, 2 ) => int result;

You can also use the ChucK Operator to call functions!

// call hey ( 1, 2 ) => hey => int result; // same hey( 1, 2 ) => int result; // several in a row ( 10, 100 ) => Std.rand2 => Std.mtof => float foo; // same 返回值做參數 Std.mtof( Std.rand2( 10, 100 ) ) => float foo;

overloading(重載)

Overloading a function allows functions with the same name to be defined(定義) with different arguments. The function must be written in separate instances(實例) to handle the input, and the return type must agree(一致).

// funk( int ) fun int add(int x) { return x + x; } // funk( int, int ) fun int add(int x, int y) { return x + y; } // compiler automatically choose the right one to call add( 1 ) => int foo; add( 1, 2 ) => int bar;
發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 湖州市| 英德市| 白河县| 广宗县| 衡南县| 卢氏县| 东台市| 周宁县| 北海市| 保德县| 成武县| 旬邑县| 依安县| 宜章县| 马公市| 南部县| 蓬安县| 昭平县| 金华市| 和平区| 石景山区| 黎城县| 石河子市| 平罗县| 江北区| 铜鼓县| 蛟河市| 宣威市| 高淳县| 康定县| 甘南县| 磐安县| 西华县| 玛纳斯县| 德化县| 马边| 扎鲁特旗| 清涧县| 临安市| 垣曲县| 嘉黎县|