Hello all,

I'm new to building node modules with cpp bindings -- I am trying to 
understand how to mimic returning a pointer for node: Here is a toy example

class myInt{
int _x;
myInt(const myInt& that);
public:
myInt(int x):_x(x){}

int getX(){
return _x;}

void setX(int x){
_x = x;}

void printX(){
std::cout<<_x<<std::endl;}};

class myIntSet{
std::vector<myInt> _myIntSet;
public:
myInt* addInt(int x){
_myIntSet.push_back(x);
return &(*(--_myIntSet.end()));}
void printLastElement(){
(*(--_myIntSet.end())).printX();}};

int main(){
myIntSet set1;
myInt* x = set1.addInt(5);
set1.printLastElement();
x->setX(1);
set1.printLastElement();
return 0;}

I have node wrappers for myInt and myIntSet as myIntWrapper and 
myIntSetWrapper respectively wrapping myInt* and myIntSet*.
However I don't know how to expose the function addInt. Basically I want to 
be able to execute the code within main in node.

Thanks for your help!
-Aashish

-- 
Job board: http://jobs.nodejs.org/
New group rules: 
https://gist.github.com/othiym23/9886289#file-moderation-policy-md
Old group rules: 
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
--- 
You received this message because you are subscribed to the Google Groups 
"nodejs" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/nodejs/b148aeac-16f7-4f4d-aa90-372dc9ca39bc%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to