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

首頁 > 學(xué)院 > 開發(fā)設(shè)計(jì) > 正文

ChucK初步(8)

2019-11-14 09:22:30
字體:
供稿:網(wǎng)友

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(括號(hào)) 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(調(diào)用)

// 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 返回值做參數(shù) 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(實(shí)例) 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;
發(fā)表評(píng)論 共有條評(píng)論
用戶名: 密碼:
驗(yàn)證碼: 匿名發(fā)表
主站蜘蛛池模板: 改则县| 东莞市| 兰溪市| 比如县| 无锡市| 威海市| 达日县| 新建县| 姚安县| 兴隆县| 陈巴尔虎旗| 乌鲁木齐县| 县级市| 舒城县| 突泉县| 凯里市| 奉新县| 铁岭市| 尼玛县| 阜阳市| 延寿县| 嘉义县| 凤台县| 孟连| 东明县| 阜新| 基隆市| 桃园县| 湘西| 赤壁市| 冷水江市| 昭觉县| 乃东县| 东至县| 蓝田县| 霍林郭勒市| 文化| 饶阳县| 辉南县| 龙海市| 临桂县|