矢量引用 c++

Vector reference c++

本文关键字:c++ 引用      更新时间:2023-10-16

我想使用对作为参数传入的向量的引用。我该怎么做?

static void sort(polygon2D& poly) {
    vector<point2D> t = poly.m_vPoint2D;
    /* the rest doesn't matter */
}

以下是创建引用的方法:

vector<point2D>& t = poly.m_vPoint2D; // here
const int n = (int) t.size(); // Call size() on the reference you have