vectors in c++...!?
Hello people!!
I am having some problems using vectors. First I do this:
#include
using namespace std;
....so that I can use vectors. Then I create a vector like this:
vector MC(10);
.....but that doesn''t work. I get compile errors like this:
error C2784: ''bool __cdecl std:perator <(const class std::reverse_iterator<`template-parameter-1'',`template-parameter-2'',`template-parameter-3'',`template-parameter-4'',`template-parameter-5''>
&,const
The point is, that I get those errors only if I pass my own class as an argument to vector. If I pass int for example,it compiles without errors. Myclass I am passing has got default constructor ( MyClass(){} ) and destructor( ~MyClass(){} ).
Please help !!!! Thanx !!
--
Uros
Life lived unexplored is life not worth living !
Since vector is a template you have to specify the type you want the array(vector) to be made of.
If you want an array of 10 integers you''d have to do this:
vector MC(10);
if you want an array of 10 floats you''d have to do this:
vector MC(10);
and so on...
If you want an array of 10 integers you''d have to do this:
vector MC(10);
if you want an array of 10 floats you''d have to do this:
vector MC(10);
and so on...
Since vector is a template you have to specify the type you want the array(vector) to be made of.
If you want an array of 10 integers you''d have to do this:
and so on...
If you want an array of 10 integers you''d have to do this:
vector<int> MC(10);//if you want an array of 10 floats you''d have to do this:vector<float> MC(10);
and so on...
Keep a vector of MyClass pointers, it''s just easier that way. Make sure to new and delete them...
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement