I want to achieve such an outcome using c++:

Java:

```
public interface ITemp {
    void onCall(double value);
}

```

In main:

```
double d=2;
ITemp mVariable = new ITemp() {
@Override
    public void onCall(double value) {
    ... what to do... you can use 'd' variable...
    }
};

```

In C++:

```
class ITemp {
public:
    virtual void onCall(double something) =0;
    virtual ~ITemp();
};

```

In main:

```
double d=2;
ITemp mVariable = .... // I cannot instantiate class containing pure virtual method
// But I want to use variable d to create a method

```