我想使用 c++ 实现这样的结果:
爪哇:
public interface ITemp {
void onCall(double value);
}
主要:
double d=2;
ITemp mVariable = new ITemp() {
@Override
public void onCall(double value) {
... what to do... you can use 'd' variable...
}
};
在 C++ 中:
class ITemp {
public:
virtual void onCall(double something) =0;
virtual ~ITemp();
};
主要:
double d=2;
ITemp mVariable = .... // I cannot instantiate class containing pure virtual method
// But I want to use variable d to create a method