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

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

ChucK初步(8)

2019-11-11 07:32:34
字體:
來源:轉載
供稿:網友

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;
發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 佛教| 遂昌县| 綦江县| 濮阳县| 饶阳县| 孟连| 华池县| 长乐市| 同仁县| 聊城市| 宿州市| 玉溪市| 正宁县| 台东市| 遂昌县| 德安县| 平塘县| 平山县| 瓦房店市| 永顺县| 姚安县| 吉隆县| 恩平市| 天长市| 夏河县| 万年县| 宁化县| 股票| 内乡县| 东安县| 云龙县| 凉城县| 玛曲县| 深泽县| 紫云| 澄城县| 富平县| 县级市| 巨鹿县| 皋兰县| 武宁县|