Initializing error

Just learned vectors and tried to initialize one but got back
error C2440: 'initializing' : cannot convert from 'initializer-list' to 'Vector<std::string>'

I've gotten this before and I'm not sure what I'm doing wrong.

1
2
3
4
#include "../../std_lib_facilities.h"
#include <vector>
int main() {
	vector<string>spellings = { "zero", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine" };
The code is correct:
https://ideone.com/XcNKxu

Make sure you are compiling in C++11 or C++14 mode.

That error message makes me nervous - is that the exact error, or did you rewrite it to your best memory? If that is the exact error message, then something is very wrong.
Last edited on
@LB
That probably is the exact error,
http://www.stroustrup.com/Programming/std_lib_facilities.h
You'll see a capital V in Vector somewhere in there, and a #define vector Vector

____
@kfann285
My guess is that Stroustrup's #defines and weird stuff going on in std_lib_facilities.h weren't meant for C++11 or C++14, and it breaks the code. That is only my assumption though.
Last edited on
@Ganado: ah, I was wondering about that header. Thanks.
That is the exact error. I'm trying to understand what's written in the header file but I'm not sure. Is there anything I can do about the error?
Use std::vector instead of vector
@LB
I've changed it to std::vector but now it is giving the error
error C2039: 'Vector' : is not a member of 'std'

I've written my code exactly how you've written it in https://ideone.com/XcNKxu.
Did you remember to #include <vector> ?
Topic archived. No new replies allowed.