Archived

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

vectors in c++...!?

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

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 !

try:
vector MC(10);

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 MC(10);

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

vector MC(10);

and so on...

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 MC(10);//if you want an array of 10 floats you''d have to do this:vector MC(10); `

and so on...

Share on other sites
Keep a vector of MyClass pointers, it''s just easier that way. Make sure to new and delete them...