Vector iterators incompatible?

You almost certainly don't want to dynamically allocate the vector; just include it as a member of the class: class Bar { std::vector _grid; } If you really want to dynamically allocate the vector, you want to use new which constructs the vector. As it is written now, you malloc space for the vector and set all the bytes occupied by the vector to zero. You never call the std::vector constructor for the allocated object, so you can't use it as a std::vector Make sure you have a good introductory C++ book from which to learn the language.

If you don't understand the C++ memory model and object model, there is now way you'll be able to write correct C++ code.

You almost certainly don't want to dynamically allocate the vector; just include it as a member of the class: class Bar { std::vector _grid; }; If you really want to dynamically allocate the vector, you want to use new, which constructs the vector. As it is written now, you malloc space for the vector and set all the bytes occupied by the vector to zero. You never call the std::vector constructor for the allocated object, so you can't use it as a std::vector.

Make sure you have a good introductory C++ book from which to learn the language. If you don't understand the C++ memory model and object model, there is now way you'll be able to write correct C++ code.

Well, I want :-) Since the index into the grid must not change over time. – Etan Dec 8 '10 at 3:31 Your hint with taking "new" helped to solve my issue. Thanks.

– Etan Dec 8 '10 at 3:32 @Etan: Your comment makes no sense. The address of the vector will not change so long as the instance of Bar of which it is a member exists. – James McNellis Dec 8 '10 at 3:35 It's a fixed size array of vectors of Foos.

– Etan Dec 8 '10 at 3:40 If it is "fixed size", then why are you allocating it dynamically? – Karl Knechtel Dec 8 '10 at 5:07.

I have a class with a std::vector data member e.g. Now the moment I reach this loop, I get the aforementioned error. I don't understand what's going on.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions