草庐IT

c++ - 如何在 Ruby-C++ 扩展中的 C++ 类中编写非静态方法?

我正在开发一个Ruby-C++扩展。我必须在CPP类中编写一个非静态方法,并且我必须使用类实例在ruby​​客户端中调用该类方法。下面是main.cpp:#include"ruby.h"#includeusingnamespacestd;classMclass{public:inti;staticVALUEnewMethod(VALUEself);staticVALUEnewInitialize(VALUEself);};VALUEMclass::newMethod(VALUEself){cout(Mclass::newMethod),0);rb_define_method(mc,"i