Abc
Abc

Reputation: 824

How to keep two vectors of points in One vector

I have a two vectors of CvPoint say

vector< CvPoint> pa, pb;

pa has 20 points and pb has 30 points;

I want to put both points in one vector, where first colum will have points of pa and second column will have points of pb.

So far, I declared a vector of both points like this:

vector <vector <CvPoint> , vector < CvPoint> > 

I know it is not right. I am not getting how can I keep two vectors in one vector. Looking for guide.

Upvotes: 2

Views: 114

Answers (1)

Alex G
Alex G

Reputation: 339

You could use an std::pair to have essentially a 2 column table of vectors;

std::vector<CvPoint> pa, pb;

...

std::pair<std::vector<CvPoint>, std::vector<CvPoint>> myPair(std::make_pair(pa, pb));

myPair.first == pa /* true */
myPair.second == pb /* true */

Upvotes: 1

Related Questions