About 73,700 results
Open links in new tab
  1. How to declare vectors in C++? - Stack Overflow

    Feb 20, 2010 · Using the following code, I get this error: ‘vector’ was not declared in this scope // Try to implement a vector of string elements #include<iostream> using namespace std; int …

  2. c++ - Initialize a vector array of strings - Stack Overflow

    Would it be possible to initialize a vector array of strings? for example: static std::vector&lt;std::string&gt; v; //declared as a class member I used static just to initialize and …

  3. c++ - Initializing a two-dimensional std::vector - Stack Overflow

    Use the std::vector::vector(count, value) constructor that accepts an initial size and a default value: std::vector<std::vector<int> > fog( ROW_COUNT, std::vector<int>(COLUMN_COUNT)); …

  4. arrays - How to initialize a vector in C++ - Stack Overflow

    Jan 18, 2012 · With the new C++ standard (may need special flags to be enabled on your compiler) you can simply do: std::vector<int> v { 34,23 }; // or // std::vector<int> v = { 34,23 }; …

  5. c++ - Declaring a 2D vector - Stack Overflow

    a has the type std::vector<std::vector<int>> which means that it is a vector of a vector. Hence your default value to fill the vector is a vector itself, not an int. Therefore the second options is …

  6. Initializing the size of a C++ vector - Stack Overflow

    It is worth mentioning that vector<Entry> phone_book(n); has different behaviors until c++11 and after c++11. Until c++11, one instance of Entry will be constructed and then copied n times. …

  7. Declaring vector as global variable in C++ - Stack Overflow

    Sep 26, 2011 · The vector itself allocates its storage on the heap, so there will be no limitations imposed upon its expansion that would be different if you instantiated the vector as a local …

  8. initialize a vector to zeros C++/C++11 - Stack Overflow

    Oct 28, 2012 · As well as being dangerous for anything except trivial types, what you wrote is pointless: constructing the vector with size length already default-initialises all of the new …

  9. c++ - What is the easiest way to initialize a std::vector with ...

    Feb 10, 2010 · I can create an array and initialize it like this: int a[] = {10, 20, 30}; How do I create a std::vector and initialize it similarly elegant?

  10. C++ How to declare and initialize a vector inside a class

    Apr 7, 2017 · Apart from what hlt said, you are using cout to print a vector of strings, but cout doesn't know how to do it. What must be done (cycling over all the values of the vector and …

Refresh