0 like 0 dislike
17 views
asked by (5.6k points)

How I can set a static array of type vector (std::vector) in the C++ programming language?

initialising a static vector array

Your answer

Try to answer the question as detailed as possible.
Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.
Anti-spam verification:
To avoid this verification in future, please log in or register.

1 Answer

0 like 0 dislike
answered by (5.6k points)

Defining and initializing a static vector array in C++:

class Foo {
public:
  static std::vector<bool> vec1;
  static std::vector<int> vec2;
  static std::vector<std::vector<int>> vec3;
  static const std::vector<int> vec4;
};
std::vector<int> Foo::vec1 = {true, false, true};
std::vector<int> Foo::vec2 = list_of(3)(5)(10); // arr of values 3, 5, 10
std::vector<std::vector<int>> Foo::vec3 = { {4, 8, 3}, {17, 5, 10}, {20, 55, 100} };
const std::vector<int> Foo::vec4 = {4, 17, 20};

Related questions

0 like 0 dislike
1 answer 25 views
0 like 0 dislike
1 answer 7 views
0 like 0 dislike
1 answer 9 views
0 like 0 dislike
1 answer 46 views
0 like 0 dislike
1 answer 13 views
0 like 0 dislike
1 answer 44 views
0 like 0 dislike
1 answer 9 views
0 like 0 dislike
1 answer 245 views
0 like 0 dislike
1 answer 25 views
0 like 0 dislike
1 answer 31 views
...