Node.js N-API ทำวัตถุอยู่ในขอบเขตวัตถุอ้างอิง

#include <napi.h>
#include "GravCalc.h"
GravCalc* gravCalc;
Napi::Value getX0(const Napi::CallbackInfo& info) {
    //int getTheAnswer(const Napi::CallbackInfo & info) {
    Napi::Env env = info.Env();
    if (gravCalc == NULL) {
        gravCalc = &GravCalc::GravCalc();
        return Napi::String::New(env, to_string(10.5));
    }
    double velocity = gravCalc->getX0Value();

    return Napi::String::New(env, to_string(velocity));
}

Napi::String setupDetails(const Napi::CallbackInfo& info)
{
    string data= info[0].As<Napi::String>();

    Napi::Env env = info.Env();
    if (gravCalc == NULL) {
        gravCalc = &GravCalc::GravCalc();
    }
    string result= gravCalc->makeCalculations(data);
    return Napi::String::New(env, result);
}