mfc出现这样的错误:error C2678: binary '==' : no operator defined which takes a left-hand operand of type 'class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >' (or there is no
 acceptable conversion)
怎么办 急急急!!!
错误指着这里错了:
int flag = 0;
CCarSystem *stu = new CCarSystem;
stu->m_spinpai = m_strpinpai;
string temp;
ifstream in("a.txt");
while(in >> temp) {
if(temp==stu->m_spinpai) {
flag = 1;
MessageBox("该品牌已存在!", "注意");
in.close();
m_strpinpai = "";
UpdateData(false); // 只将学号清空,其余信息保留
return;
}
}
in.close();有==那里

解决方案 »

  1.   

    试试用 string::compare
      

  2.   

    if(strcmp(temp.c_str(),stu->m_spinpai)==0) {
      

  3.   

    stu 的类型定义是怎么样的??要告诉大家
      

  4.   


    void Add::write(CCarSystem *stu)
    {
    stu->m_spinpai=m_strpinpai;
    stu->m_syanse = m_stryanse;
    stu->m_sleibie = m_strleibie; ofstream ou;
    ou.open("a.txt", ios::app);
    ou << left;
    ou << setw(20) << stu->m_spinpai;
    ou << setw(20) << stu->m_syanse;
    ou << setw(20) << stu->m_sleibie;
    ou << endl;
    ou.close();}
      

  5.   

    CCarSystem 的定义 ?
      

  6.   

    ofstream of;
    of.open("a.txt", ios::app);
    of << left;
    of << setw(20) << "stu->m_spinpai";
    of << setw(20) << "stu->m_syanse";
    of << setw(20) << "stu->m_sleibie";
    of << endl;
    of.close();//结果: stu->m_spinpai      stu->m_syanse       stu->m_sleibie 
    可见 stu 有 问题 !