//haxe: 类 对象 new 和 构造函数
package;
import neko.Lib;
import neko.io.File;
#end
class Thing
{
public function new(){trace("new from class Thing");
}
public function asd() {
App.x=2;
trace("Thing: asd()");
}
}
class App
{
public static var x:Int;//need a confirmed Type
public function new(){ trace("new App();"); }// new() for new method
public static function demo1() {
var v1=3.1,v2=5,v3=2,v4=2.0;
trace("python: "+v1+"**"+v2+"**"+v3+"**"+v4+'');
var v=Math.pow(v1,Math.pow(v2,Math.pow(v3,v4)));
trace(" = "+v);
}
function asd() {//default: private dynamic
trace("App: asd");
}
static function main()
{ //var trace!=Sys.println;
trace("####begin");var p1=new Thing();//the new methods
App.demo1;//not run without "()"
new App().asd();
new App();//self new
trace("App.demo1= "+App.demo1);//output is:App.demo1= (function)
trace("####end");
}
}
/* output is:
####begin
new from class Thing
new App();
App: asd
new App();
App.demo1= <function>
####end
*/