Link to home
Start Free TrialLog in
Avatar of Unimatrix_001
Unimatrix_001Flag for United Kingdom of Great Britain and Northern Ireland

asked on

Using vectors and references - Cannot convert from vector to &

Hi.

void setBit(BIT &aBit, const bool aValue){
      if(aValue)
            aBit=1;
      else
            aBit=0;
}

int main(){
      vector<BIT> bitVec[3];
      setBit(bitVec[0], false);
      setBit(bitVec[1], false);
      setBit(bitVec[2], false);
      return false;
}

I get errors about not being able to convert from a std::vector to 'BIT &'?
ASKER CERTIFIED SOLUTION
Avatar of DefreeComan
DefreeComan

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Unimatrix_001

ASKER

Thanks. I knew it would be something silly... Time to sleep I think. :)
Avatar of Infinity08
Actually, you'd better use :

        vector<BIT> bitVec(3);

(to reserve space for 3 BITs in the vector) because immediately after you try to access the vector using bitVec[0], bitVec[1] and bitVec[2].