Archived

This topic is now archived and is closed to further replies.

JaZsT

vectors in c++...!?

Recommended Posts

JaZsT    122
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 !

Share this post


Link to post
Share on other sites
Gladiator    127
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...

Share this post


Link to post
Share on other sites
Gladiator    127
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<int> MC(10);

//if you want an array of 10 floats you''d have to do this:


vector<float> MC(10);


and so on...

Share this post


Link to post
Share on other sites