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 char
s (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 char
s (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
Using Struct Keyword in Variable Declaration in C++
Detect If Program Is Running with Full Administrator Rights
How to Delete a Non-New Object
How to Add 2 Arbitrarily Sized Integers in C++
Forward Declare a Standard Container
Why Doesn't My Template Accept an Initializer List
Converting String of 1S and 0S into Binary Value
Construct Path for #Include Directive with MACro
How to Cout a Float Number with N Decimal Places
False Positive with Is_Copy_Constructible on Vector<Unique_Ptr>
Istream Behavior Change in C++ Upon Failure
Destructor Being Called Twice When Being Explicitly Invoked
How to Modify Values in a Map Using Range Based for Loop