Point为一个结构体,出现如下警告:
无法用"Point*”类型的值初始化"Point &”类型的引用(非常量限定)联机搜索
struct Point{
/********代码*********/
};
int findMaxDepth(Point& p){
/********代码*********/
}
int main{
vector<Point*> points;
for (auto&& p : points) {
findMaxDepth(p);
//无法用"Point*”类型的值初始化"Point &”类型的引用(非常量限定)联机搜索
}
}
此时,只需要将p改成*p就好啦,这样解引用,传递的参数就是一个Point类型
for (auto&& p : points) {
findMaxDepth(*p);
}