Storing an array of coordinate sets in C ++ (vector of pairs vector?)

First of all, I am very new to C ++, so I may have to plunge into pseudocode and / or Python to explain what I'm trying to do ...

I am trying to save pairs of X and Y coordinates for each frame of the animation, for multiple sprites. I assumed that it was something like the following: suppose PLAIN == 1 (using an enumeration):

animationFrames[PLAIN][0] = { 20, 50 }
animationFrames[PLAIN][1] = { 25, 55 }

Et cetera. In fact, I would like to be able to request animated frames with a sprite identifier and get a set of X, Y coordinates for iteration. I find it rather complicated. Here is my attempt, which does not work ...

std::vector< std::vector< std::pair<int, int> > > frames = {
    {
        { 1, 1 }, { 2, 2 }  // two frames for sprite A
    },
    {
        { 3, 3 }, { 4, 4 }  // two frames for sprite B
    }
};

As a result, you receive the following error message:

prog.cpp: In function 'int main()':
prog.cpp:15: error: braces around initializer for non-aggregate type 'std::vector<std::vector<std::pair<int, int>, std::allocator<std::pair<int, int> > >, std::allocator<std::vector<std::pair<int, int>, std::allocator<std::pair<int, int> > > > >'

I have tried various mutations of vectors, pairs and arrays, but I cannot figure it out.

Thanks in advance!

+4
1

, , , ++ 11, , . :

std::vector<std::vector<std::pair<int, int> > > frames(2);
std::vector<std::pair<int, int> > &v1 = frames[0];
v1.push_back(std::pair<int, int>(1, 1));
v1.push_back(std::pair<int, int>(2, 2));
std::vector<std::pair<int, int> > &v2 = frames[1];
v2.push_back(std::pair<int, int>(3, 3));
v2.push_back(std::pair<int, int>(4, 4));

, . , , ++ 11, =, :

std::vector<std::vector<std::pair<int, int>>> frames {
    {
        { 1, 1 }, { 2, 2 }  // two frames for sprite A
    },
    {
        { 3, 3 }, { 4, 4 }  // two frames for sprite B
    }
};
+1

All Articles