Jump to content
  • Advertisement

Archived

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

vectors in c++...!?

This topic is 6063 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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
Advertisement
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
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

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!