C Header file

Creator
Creator
Seonglae ChoSeonglae Cho
Created
Created
2020 Jun 22 2:5
Editor
Edited
Edited
2024 Jun 12 7:34
Refs
Refs
header file does not have difference with cc or cpp file
It is just convention
 
 
 

Class Header file

header
class PiWorker : public Napi::AsyncWorker { public: PiWorker(Napi::Env &env, int points) : Napi::AsyncWorker(env), points(points), estimate(0), deferred(Napi::Promise::Deferred::New(env)) {} ~PiWorker() {} void Execute(); void OnOK(); void OnError(Napi::Error const &error); Napi::Promise GetPromise(); private: int points; double estimate; Napi::Promise::Deferred deferred; };
 
 
body
void PiWorker::OnOK() { Object obj = Napi::Object::New(Env()); obj.Set("estimate", Number::New(Env(), estimate)); deferred.Resolve(obj); } void PiWorker::Execute() { estimate = 4.0; } void PiWorker::OnError(Error const &error) { deferred.Reject(error.Value()); } Promise PiWorker::GetPromise() { return deferred.Promise(); }
 
 
 
Separating class code into a header and cpp file
Asked I am confused on how to separate implementation and declarations code of a simple class into a new header and cpp file. For example, how would I separate the code for the following class?
Separating class code into a header and cpp file
 
 

Recommendations