0

I tried to make character by character comparison under string type, with the following code:

vector <int> getQuality(string seedTag, vector <string> &MuTag) { 

    vector <int> Quals;  

     for (unsigned i = 0; i<MuTag.size(); i++) { 
         Quals.push_back(-40);
         cout << MuTag[i] << " " << seedTag[i] << endl;

         if (MuTag[i] == seedTag[i]) { // This line 33 with error
           Quals.push_back(40);
         }


     }

     return Quals;
}

But why it gives such error:

 Mycode.cc:33: error: no match for 'operator==' in '(+ MuTag)->std::vector<_Tp, _Alloc>::operator[] [with _Tp = std::string, _Alloc = std::allocator<std::string>](((long unsigned int)i)) == seedTag. std::basic_string<_CharT, _Traits, _Alloc>::operator[] [with _CharT = char, _Traits = std::char_traits<char>, _Alloc = std::allocator<char>](((long unsigned int)i)

How can I resolve it?

4 Answers 4

7

You are trying to compare a string (MuTag[i]) with a char (seedTag[i]).

Sign up to request clarification or add additional context in comments.

Comments

4

As Alexander said, you are comparing a string and a char.

The sad thing is that the compiler already told you that, only it encrypted it in ISO-STL-TEMPLATE encryption, which is more difficult to read that perl!

You may want to look at this script for decrypting C++ STL error messages.

Comments

2

I know plenty of other people have given a response to what is causing the compilation error, so let me recap and then propose a solution:

seedTag is a string, which by definition is an ordered collection of characters. MuTag is defined as a vector of strings: an ordered collection of strings.

When you do your comparison:

MuTag[i] == seedTag[i]

as other people have said, you're not comparing the same type.

To fix it:

By the looks of things, you're wanting to compare each of the values in MuTag with seedTag. If that is indeed the case, just get rid of the [i] in "seedTag[i]".

Comments

1
vector <string> & MuTag

is collection of strings , while

string seedTag

is collection of chars. So in you comparison

MuTag[i] == seedTag[i]

you actually comparing something like this

 "aaaaa" == 'a'

which is definitely not correct.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.