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

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

ChucK初步(8)

2019-11-11 06:54:19
字體:
來源:轉載
供稿:網友

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;
上一篇:點到平面的距離

下一篇:模板初探

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 柘城县| 德令哈市| 兴业县| 安仁县| 苍梧县| 通化市| 廊坊市| 商城县| 农安县| 都昌县| 常熟市| 林甸县| 调兵山市| 安塞县| 武定县| 新津县| 紫金县| 辽阳市| 洛川县| 滨海县| 宁夏| 绥化市| 武定县| 东城区| 九江县| 义乌市| 吴川市| 迭部县| 宣化县| 若尔盖县| 北票市| 盱眙县| 利川市| 汕尾市| 贵州省| 修水县| 湟中县| 邵武市| 清水河县| 沙雅县| 于都县|