0

error in this line when create vector program in cpp program and how to resolve in dev cpp editor

vector<int> v={12,24,56,45,32,76};
drescherjm
  • 10,365
  • 5
  • 44
  • 64
vikash chander
  • 49
  • 1
  • 10
  • Does this answer your question? [What is the easiest way to initialize a std::vector with hardcoded elements?](https://stackoverflow.com/questions/2236197/what-is-the-easiest-way-to-initialize-a-stdvector-with-hardcoded-elements) – Catweazle Mar 15 '20 at 15:06

2 Answers2

1

You can create a an array first that you then use with the vector constructor that takes iterators.

Example:

#include <vector>

template<typename T, size_t N>
size_t size(const T(&)[N]) {
    return N;
}

int main() {
    int arr[] = {12,24,56,45,32,76};

    std::vector<int> v(arr, arr+size(arr));
}
Ted Lyngmo
  • 93,841
  • 5
  • 60
  • 108
0

I also got this Issue & has been fixed.

In Devc++ ,

Go to

Tool > Compiler Options > Settings > Code Generation

& Set "Language Standard" to "ISO C++11"

No need any other changes.See this

machineman
  • 31
  • 5