如何从返回向量的函数中获取向量值?

how to get the vector value from function returning a vector?

我在 VS 2015 中编译我的程序时遇到错误:

call of an object of a class type without appropriate operator() or conversion functions to pointer-to-function type

它用红色标记函数调用,returns 一个向量。这是代码:

struct punct {
int x, y, val;
};

int koli4estvoShagov = 0;
int arr[100][100];
int n, m;

vector<punct> shag(int x, int y, int nrShaga) {
punct shag;
shag.val = arr[x][y];
shag.x = x;
shag.y = y;
vector<punct> shagi;
shagi.push_back(shag);

if (nrShaga == koli4estvoShagov - 1) {
    return shagi;
}
else if (x == m - 1) {
    vector<punct> shagVNiz = shag(x, y + 1, nrShaga + 1);
    shagi.insert(shagi.end(), shagVNiz.begin(), shagVNiz.end());
    return shagi;
}
else if (y == n - 1) {
    vector<punct> shagVPravo = shag(x + 1, y, nrShaga + 1);
    shagi.insert(shagi.end(), shagVPravo.begin(), shagVPravo.end());
    return shagi;
}
else {
    vector<punct> shagVPravo = shag(x + 1, y, nrShaga + 1);
    vector<punct> shagVNiz = shag(x, y + 1, nrShaga + 1);
    vector<punct> max;
    if (sum(shagVNiz) > sum(shagVPravo))
        max = shagVNiz;
    else
        max = shagVPravo;

    shagi.insert(shagi.end(), max.begin(), max.end());
    return shagi;
}
}

具体看函数的调用"shag".

vector<punct> shag(int x, int y, int nrShaga) {
punct shag;

局部变量shag与函数同名。