A
A
Arthur2014-09-25 16:45:32
C++ / C#
Arthur, 2014-09-25 16:45:32

What's wrong with vectors?

Hey!
I'm studying C++ recently, I'm reading Stanley B. Lippman's book - "The C++ Programming Language. Basic Course". Here.
I have a few questions about vectors.
1) When I declare a vector and set the data explicitly, this is what I mean:
vector<int> v{1, 2, 3, 4, 5};
The compiler throws an error.
1)expected primary-expression before "v"
2)expected `;' before "v"
2) When trying to access elements with an iterator, like this:
auto iter = v.begin();
1)ISO C++ forbids declaration of `iter1' with no type
2) cannot convert `__gnu_cxx::__normal_iterator > >' to `int' in initialization
Again it throws an error.
What is the problem?
ps I'm using the DEV C++ program.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
J
jcmvbkbc, 2014-09-25
@Biomorphix

The compiler throws an error.
...
Again, it throws an error.
What is the problem?
The fact that you did not give us the text of the error.
At random, your compiler doesn't support C++0x

M
Maxim, 2014-09-25
@1kachan

try compiling with -std=c++11

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question