Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Foo{
- static vector<Point> vec[3];
- };
- vec[0] = { {1,2}, {3,4}}; // contain two points
- vec[1] = { {0, 0}}; // contain one point
- vec[2] = {}; // empty
- vector<Poiint> Foo::vec={Point(1,2,3), Point(4,5,6), Point(8,9,10)};
- static vector<Point> vec;
- Class Foo{
- public:
- static int bar;
- static class _init{
- public _init(){// do something to bar}
- } Initializer;
- };
- // --- in .cpp
- // define 'bar' and 'Initializer'
- static vector < vector<Point> > vec;
- vec.push_back( {{1,2}, {3,4}} );
- vec.push_back( {{0,0}} );
- vec.push_back( {{4,5}} );
- //
- // Declared a typedef to separate the vector row and the whole matrix
- // Makes it simpler to traverse each vector row later. intVals is a
- // test class with public integer elements "a" and "b". The intVals
- // class substitutes for the Point type in the OP above.
- //
- typedef vector<intVals> vec_t;
- vector<vec_t> matrix;
- int jj;
- for (int i = 0; i < 3; i++)
- {
- jj = 0;
- for (vec_t::iterator j = matrix[i].begin(); j != matrix[i].end(); j++)
- {
- cout << "Matrix at index: " << i << ", element: " << jj << " a = " << (*j).a;
- cout << " b = " << (*j).b << endl;
- jj++;
- }
- }
- vec[0] = { {1,2}, {3,4}};
- Point v1[2] = {Point(1,2), Point(3,4)};
- Point v2[1] = {Point(0.0)};
- vector<Point> Foo::vec[] = {vector<Point>(v1, v1+2), vector<Point>(v2, v2+1), vector<Point>()};
- vector<Point> Foo::vec[] = {{Point(1,2), Point(3,4)}, {Point(0,0)}, {}};
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement