Home > Software engineering >  The error C2678: binary '==' : no operator defined which takes a left - hand operand
The error C2678: binary '==' : no operator defined which takes a left - hand operand

Time:09-29

MFC appear such error: error C2678: binary '==' : no operator defined which takes a left - hand operand of type 'class STD: : basic_string & lt; Char, struct STD: : char_traits & lt; Char> Class, STD: : allocator '(or there is no
Acceptable conversion)
? Urgent urgent!!!!!!
Error pointing to the wrong here:
Int flag=0;
Stu CCarSystem *=new CCarSystem;
Stu - & gt; M_spinpai=m_strpinpai;
String temp;
Ifstream in (" a.t xt ");
While (in & gt;> Temp) {
If (temp==stu - & gt; M_spinpai) {
Flag=1;
MessageBox (" the brand already exists!" "Notice");
In the close ();
M_strpinpai="";
The UpdateData (false);//student id to empty, only keep the rest of the information
return;
}
}
In the close ();

There are==there

CodePudding user response:

Left and right side type, can't conversion, so can't compare

CodePudding user response:

Try to use the string: : compare

CodePudding user response:

If (STRCMP (temp. C_str (), stu - & gt; M_spinpai)==0) {

CodePudding user response:

The
reference 3 floor schlafenhamster response:
if (STRCMP (temp. C_str (), stu - & gt; M_spinpai)==0) {


Changed the no is wrong, but how write text document's data is not broken, a query function, check out

CodePudding user response:

refer to the second floor zgl7903 response:
try string: : compare


Use the or incorrect

CodePudding user response:

"Write text document's data is not what"
Look at the code

CodePudding user response:

What is the type definition of stu?? To tell you

CodePudding user response:

Obviously do not match the type of error, strong turn feasible?

CodePudding user response:

refer to 6th floor schlafenhamster response:
"write text document's data is not what"
Look at the code


Void the Add: : write (CCarSystem * stu)
{
Stu - & gt; M_spinpai=m_strpinpai;
Stu - & gt; M_syanse=m_stryanse;
Stu - & gt; M_sleibie=m_strleibie;

Ofstream ou;
Ou. Open (" a.t xt ", the ios: : app);
Ou & lt; Ou & lt; Ou & lt; Ou & lt; Ou & lt; Ou. The close ();

}

CodePudding user response:

The definition of CCarSystem?

CodePudding user response:

Ofstream of;
Of the open (" a.t xt ", the ios: : app);
Of & lt; Of & lt; Of & lt; Of & lt; Of & lt; Of the close ();//the result: stu - & gt; M_spinpai stu - & gt; M_syanse stu - & gt; M_sleibie
There is something wrong with the visible stu!
  • Related