no match for operator

this error could be in many forms like

no match for "operator<"
no match for "operator>"
no match for "operator+"
no match for "operator<"
no match for "operator*"
no match for "operator++"

basically any of the operators 

99% of the time if you look at the value on the left side of the operator is not compatable with the value on the right side of the operator






File: main1.cpp 


#include "cmpslib19.h" // all the special functions provided for this class


class dog
{
public:
string name;
int age;
double weight;


}; // end class dog


int main()
  {

  dog d1;

  d1.age = 7; // ok
  d1.name ="rover";

  if (d1.age == d1.name) 
    {
	cout << "d1 age and name are equal \n";
	}





  return 0;
  }

this will generate about 3 pages worth of feedback from the compiler. mostly these will be it suggesting possible solutions but it makes it confusing So as always scroll up to the top and look at the very beginning of the error output. here are the first few lines msarr@odin> make g++ -Wall -o runme1 main1.cpp main1.cpp: In function 'int main()': main1.cpp:24:14: error: no match for 'operator==' (operand types are 'int' and 'std::__cxx11::string' {aka 'std::__cxx11::basic_string'}) if (d1.age == d1.name) ~~~~~~~^~~~~~~~~~ In file included from /usr/include/c++/8/bits/stl_algobase.h:64, from /usr/include/c++/8/bits/char_traits.h:39, from /usr/include/c++/8/string:40, from /usr/include/c++/8/bitset:47, from cmpslib19.h:4, from main1.cpp:2: It tells you where the error is located, file, function , line number and column it prints out that line and even puts a little arrow pointing to the operator the compiler is confused because it cannot perform that operation. here it says i dont know what to do for operator == furthermore it then lists the operands... ( values on the right and left of the operator) operand types are 'int' and 'std::__cxx11::string' it says int ( on the left) and std::__cxx11:string ( on the right) so basically it says I DO NOT KNOW HOW to determine if the integer on the left is equal to the string on the right These errors are usually when you are trying to use an operator with two different data types you cant compare and int pointer with an int, or a string with a double imagine that you have 3 variables, one is an int and one is a string and one is a pointer if you get confused and mix up the variables you could easily make an error like this, so look at what the compiler is telling you is the data type of the right value and the datatype of the left value... 99% of the time you have either the right or left value wrong.