"term does not evaluate to a function taking 0 arguments"错误

"term does not evaluate to a function taking 0 arguments" error

本文关键字:taking arguments 错误 function to term does not evaluate      更新时间:2023-10-16
template <typename T>
    class Sorteermethode {
    public:
        virtual void operator()(vector<T> & v) const = 0;
        void meet(int kortste, int langste, ostream& os) {
            Sortvector<T> * mijnVector = new Sortvector<T>(kortste);
            Chrono * chrono = new Chrono;
            while (kortste <= langste) {
                (*mijnVector).vul_range();
                (*chrono).start();
                this()(*mijnVector);
                (*chrono).stop();
                printf("Lengte: %d tijd: %f", kortste, (*chrono).tijd());
                kortste *= 10;
                (*mijnVector).resize(kortste);
            }
            free(chrono);
            free(mijnVector);
        };
    };

当我尝试调用先前定义的运算符 () 时,出现以下错误:

Severity    Code    Description Project File    Line
Error   C2064   term does not evaluate to a function taking 0 arguments Algoritmen1 c:usersuserdocumentsvisual studio 2015projectsalgoritmen1algoritmen1sorteermethode.h    40

谁能给我一些见解?据我所知,它没有解析为带有一个参数的函数。

这个:

this()(*mijnVector);

正在尝试调用this指针。你想要调用它指向的对象。正确的语法是:

(*this)(*mijnVector);

或者,如果你觉得特别罗嗦:

this->operator()(*mijnVector);