C++ – Expression cannot be used as a function

  c++

While I trying compile my very old game source, I got this error below:

game.h:497:16: error: expression cannot be used as a function
       (_f2)(arg);
                ^
make: *** [Makefile:20: actions.o] Error 1

This is my game.h file:

template<class ArgType>
class TCallList : public SchedulerTask{
public:
    TCallList(
        boost::function<bool(Game*, ArgType)> f1,
        Task* f2,
        std::list<ArgType>& call_list,
        int64_t interval) :
            _f1(f1), _f2(f2), _list(call_list), _interval(interval)
    {
        //
    }
    
    virtual void operator()(Game* arg)
    {
        if(_eventid != 0){
            bool ret = _f1(arg, _list.front());
            _list.pop_front();

            if(ret){
                if(_list.empty()){
                    //callback function
                    if(_f2){
                        (_f2)(arg);
                        delete _f2;
                    }
                }
                else{
                    //fire next task
                    SchedulerTask* newTask = new TCallList(_f1, _f2, _list, _interval);
                    newTask->setTicks(_interval);
                    newTask->setEventId(this->getEventId());
                    arg->addEvent(newTask);
                }
            }
        }
    }

My operation system is latest Debian 10 with updates.

Edit:

My source available on github: https://github.com/anyeor/oldsrc

Source: Windows Questions C++

LEAVE A COMMENT