Error C2679: Binary '<<':No Operator Found Which Takes a Right-Hand Operand of Type 'Std::String' (Or There Is No Acceptable Conversion)

error C2679: binary ' ' : no operator found which takes a right-hand operand of type 'std::string' (or there is no acceptable conversion)

Have you included all of the following headers?

  • <fstream>
  • <istream>
  • <iostream>
  • <string>

My guess is you forgot <string>.

On a side note: That should be std::cout and std::endl.

error C2679: binary ' ': no operator found which takes a right-hand operand of type 'std::vector char,std::allocator char '

At this line

cout << values;

you are trying to call the std::basic_ostream::operator<< for vector of chars (i.e.std::vector<char> values). This is not defined, therefore the compiler does not know about it. Hence, the error.

You need to iterate through the elements of the vector of chars (i.e. values). For example, using range based for loop:

for (const char ele : values)
std::cout << ele << " ";

That being said, you could have used simply std::string instead of std::vector<char> for which you have already operator<< available from the standard.

error C2679: binary ' ': no operator found which takes a right-hand operand of type 'std::string_view' (or there is no acceptable conversion)

Like others already mentioned - std::string_view is defined in the standard header "string_view", which must be included - otherwise string_view is not defined.

Because you include some headers like "string" and "iostream" which have some connection to std::string_view it is clear that they do at least some forward_declarations.

In some implementations string_view might be already included in other system headers.
For example std::string_view could be implemented/defined in the header "string" and the header "string_view" could just include "string".

But in general this is an implementation detail of the library implementation. To be able to use std::string_view, it is required to include that header.

error C2679: binary ' ' : no operator found which takes a right-hand operand of type 'int' (or there is no acceptable conversion)

If I reorder and fix the #includes, there are at least two mistakes in your code. first, this does not compile:

friend double operator += (const SquareTriangle &first, const SquareTriangle &second)
{
first.getArea() += second.getArea();
return first.getArea();
}

Because you are trying to assign something to an expression. If you want to increase first's area, you will have to modify the data members (the catheti). Not sure why you are doing it, because it does not make much sense anyway.


Second, this if line does not compile:

if (ptr[i] > valueST)
{
count++;
}

Because ptr[i] ends up being an integer, and valueST is an instance of your class. Since you don't have a way to compare an int with a SquareTriangle, it breaks. Not sure what you are trying to do, though. Comparing with the area, maybe?

Error C2679 binary ' ': no operator found which takes a right-hand operand of type 'T'

My bad, one of the calls was with a 'class enum'. Of course, >> and << are not defined for it.



Related Topics



Leave a reply



Submit