Advertisement
Guest User

Untitled

a guest
Apr 25th, 2014
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.43 KB | None | 0 0
  1. class Foo{
  2. static vector<Point> vec[3];
  3. };
  4.  
  5. vec[0] = { {1,2}, {3,4}}; // contain two points
  6. vec[1] = { {0, 0}}; // contain one point
  7. vec[2] = {}; // empty
  8.  
  9. vector<Poiint> Foo::vec={Point(1,2,3), Point(4,5,6), Point(8,9,10)};
  10.  
  11. static vector<Point> vec;
  12.  
  13. Class Foo{
  14. public:
  15. static int bar;
  16. static class _init{
  17. public _init(){// do something to bar}
  18. } Initializer;
  19. };
  20.  
  21. // --- in .cpp
  22. // define 'bar' and 'Initializer'
  23.  
  24. static vector < vector<Point> > vec;
  25.  
  26. vec.push_back( {{1,2}, {3,4}} );
  27. vec.push_back( {{0,0}} );
  28. vec.push_back( {{4,5}} );
  29.  
  30. //
  31. // Declared a typedef to separate the vector row and the whole matrix
  32. // Makes it simpler to traverse each vector row later. intVals is a
  33. // test class with public integer elements "a" and "b". The intVals
  34. // class substitutes for the Point type in the OP above.
  35. //
  36. typedef vector<intVals> vec_t;
  37. vector<vec_t> matrix;
  38.  
  39.  
  40. int jj;
  41. for (int i = 0; i < 3; i++)
  42. {
  43. jj = 0;
  44. for (vec_t::iterator j = matrix[i].begin(); j != matrix[i].end(); j++)
  45. {
  46. cout << "Matrix at index: " << i << ", element: " << jj << " a = " << (*j).a;
  47. cout << " b = " << (*j).b << endl;
  48. jj++;
  49. }
  50. }
  51.  
  52. vec[0] = { {1,2}, {3,4}};
  53.  
  54. Point v1[2] = {Point(1,2), Point(3,4)};
  55. Point v2[1] = {Point(0.0)};
  56.  
  57. vector<Point> Foo::vec[] = {vector<Point>(v1, v1+2), vector<Point>(v2, v2+1), vector<Point>()};
  58.  
  59. vector<Point> Foo::vec[] = {{Point(1,2), Point(3,4)}, {Point(0,0)}, {}};
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement