0 like 0 dislike
5 views
asked by (4.7k 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

pre, code

Preview

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 (4.7k 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 21 views
0 like 0 dislike
1 answer 23 views
0 like 0 dislike
1 answer 5 views
0 like 0 dislike
1 answer 36 views
0 like 0 dislike
1 answer 136 views
0 like 0 dislike
1 answer 16 views
0 like 0 dislike
1 answer 22 views
0 like 0 dislike
1 answer 22 views
0 like 0 dislike
1 answer 10 views
...