Does anyone know how to call the vector pointer so that it can be assigned to an integer? Following is the code:
有谁知道如何调用向量指针,以便它可以分配给一个整数?以下是代码:
void floodFillwithColor(vector<vector<int>>* M, int x, int y, int newC){
int* prevC = M[x][y];
int* newCPtr = &newC;
floodFillUtil(M, x, y, prevC, newCPtr);
};
1 个解决方案
#1
2
how to call the vector pointer so that it can be assigned to an integer?
如何调用向量指针使其可以分配给整数?
You cannot call a vector pointer, but you can use the indirection operator to get a reference to the pointed object, and then apply the subscript operator on that reference:
您不能调用向量指针,但可以使用间接运算符来获取对指向对象的引用,然后对该引用应用下标运算符:
if(M)
int some_value = (*M)[x][y]; // assign to an integer
else
// handle the case where M is null
#1
2
how to call the vector pointer so that it can be assigned to an integer?
如何调用向量指针使其可以分配给整数?
You cannot call a vector pointer, but you can use the indirection operator to get a reference to the pointed object, and then apply the subscript operator on that reference:
您不能调用向量指针,但可以使用间接运算符来获取对指向对象的引用,然后对该引用应用下标运算符:
if(M)
int some_value = (*M)[x][y]; // assign to an integer
else
// handle the case where M is null