[hxcpp] question about create new class instance in cpp


import cpp.link.StaticRegexp;
import cpp.link.StaticStd;
import cpp.link.StaticZlib;

class Empty 
	public var word:String;
	public function new (){
		word = "hello,welcome to haxe";
	public function say():Void{
		trace("call haxe function say" + word);
 static function main() {
        trace('hello empty library');

    static function test() {
        trace('hello test function');
	static function crateNew():Empty{
		return new Empty();



	Empty_obj *ab = new Empty_obj();//is this right?

	ab->say();//error 2001?why?


libEmpty-debug.lib instead of libEmpty.lib to link

When you’re not sure on how to use the c+ generated code do it in haxe and look at how it’s done.

It seems you need to do hx::ObjectPtr<Empty_obj> ab = Empty_obj::__alloc(HX_CTX), or at least if you use new you need to call ab->__construct() to call the haxe constructor and init the object.