error C2678: binary '==' : no operator defined which takes a left-hand operand

轨迹- 2017-06-14 11:53:58
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();

有==那里
...全文
348 11 打赏 收藏 转发到动态 举报
写回复
用AI写文章
11 条回复
切换为时间正序
请发表友善的回复…
发表回复
schlafenhamster 2017-06-20
  • 打赏
  • 举报
回复
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 有 问题 !
schlafenhamster 2017-06-20
  • 打赏
  • 举报
回复
CCarSystem 的定义 ?
Anow_D 2017-06-19
  • 打赏
  • 举报
回复
明显的类型不一致报错,强转可行吗?
sevancheng 2017-06-19
  • 打赏
  • 举报
回复
stu 的类型定义是怎么样的??要告诉大家
轨迹- 2017-06-19
  • 打赏
  • 举报
回复
引用 6 楼 schlafenhamster 的回复:
“写入文档的数据不是文字 怎么” 看看代码
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(); }
轨迹- 2017-06-15
  • 打赏
  • 举报
回复
引用 2 楼 zgl7903 的回复:
试试用 string::compare
用了这个还是有错误
轨迹- 2017-06-15
  • 打赏
  • 举报
回复
引用 3 楼 schlafenhamster 的回复:
if(strcmp(temp.c_str(),stu->m_spinpai)==0) {
改了这个没有错了,可是写入文档的数据不是文字 怎么破,有个查询功能的,查不出来
schlafenhamster 2017-06-15
  • 打赏
  • 举报
回复
if(strcmp(temp.c_str(),stu->m_spinpai)==0) {
zgl7903 2017-06-15
  • 打赏
  • 举报
回复
试试用 string::compare
ckc 2017-06-15
  • 打赏
  • 举报
回复
左右两边类型不等,无法转换,所以不能比较
schlafenhamster 2017-06-15
  • 打赏
  • 举报
回复
“写入文档的数据不是文字 怎么” 看看代码
笔记本的风扇控制 ---------------------------------------- 09 November 2006. Summary of changes for version 20061109: 1) ACPI CA Core Subsystem: Optimized the Load ASL operator in the case where the source operand is an operation region. Simply map the operation region memory, instead of performing a bytewise read. (Region must be of type SystemMemory, see below.) Fixed the Load ASL operator for the case where the source operand is a region field. A buffer object is also allowed as the source operand. BZ 480 Fixed a problem where the Load ASL operator allowed the source operand to be an operation region of any type. It is now restricted to regions of type SystemMemory, as per the ACPI specification. BZ 481 Additional cleanup and optimizations for the new Table Manager code. AcpiEnable will now fail if all of the required ACPI tables are not loaded (FADT, FACS, DSDT). BZ 477 Added #pragma pack(8/4) to acobject.h to ensure that the structures in this header are always compiled as aligned. The ACPI_OPERAND_OBJECT has been manually optimized to be aligned and will not work if it is byte-packed. Example Code and Data Size: These are the sizes for the OS- independent acpica.lib produced by the Microsoft Visual C++ 6.0 32- bit compiler. The debug version of the code includes the debug output trace mechanism and has a much larger code and data size. Previous Release: Non-Debug Version: 78.1K Code, 17.1K Data, 95.2K Total Debug Version: 155.4K Code, 63.1K Data, 218.5K Total Current Release: Non-Debug Version: 77.9K Code, 17.0K Data, 94.9K Total Debug Version: 155.2K Code, 63.1K Data, 218.3K Total 2) iASL Compiler/Disassembler and Tools: Fixed a problem where the presence of the _OSI predefined control method within complex expressions could cause an internal compiler error. AcpiExec: Implemented full region support for multiple address spaces. SpaceId is now part of the REGION object. BZ 429 ---------------------------------------- 11 Oc
FASMARM v1.42 This package is an ARM assembler add-on for FASM. FASMARM currently supports the full range of instructions for 32-bit and 64-bit ARM processors and coprocessors up to and including v8. Contents: 1. ARM assembly compatibility 2. UAL and pre-UAL syntaxes 3. IT block handling 4. Alternate encodings 5. Output formats 6. Control directives 7. Data definitions 8. Defining registers lists inside macros 9. Half-precision number formatting 10. Variants supported 11. Further information 12. Version history _______________________________________________________________________________ 1. ARM assembly compatibility There are a few restrictions how the ARM instruction set is implemented. The changes are minor and mostly have a minor impact. For the most part the basic instruction outline is the same. Where possible the original style is used but there are some differences: Not everything matches the ARM ADS assembly style, where possible the original style is used but there are some differences 1) label names cannot begin with a digit 2) CPSIE and CPSID formats are changed, use "iflags_aif" form instead of "aif" (eg. "CPSIE iflags_i" instead of "CPSID i") 3) SRS with writeback must have a separating space after the mode number and before "!" (eg. "SRSDB 16 !" instead of "SRSDB 16!") 4) macro, rept, irp, format, if, virtual etc. are all significant changes from the ARM ADS, so you will need to re-write those sections of existing code Original ARM Syntax | fasmarm Syntax ----------------------+---------------------- cpsie a | cpsie iflags_a | srsdb #29! | srsdb #29 ! ;or, | srsdb 29 ! _______________________________________________________________________________ 2. UAL and pre-UAL syntaxes fasmarm supports the original pre-UAL syntax and the newer UAL syntax. These two syntaxes only affect THUMB encodings. UAL stands for: Universal Assembly Language. pre-UAL syntax is selected wi

16,472

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC相关问题讨论
社区管理员
  • 基础类社区
  • Web++
  • encoderlee
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

        VC/MFC社区版块或许是CSDN最“古老”的版块了,记忆之中,与CSDN的年龄几乎差不多。随着时间的推移,MFC技术渐渐的偏离了开发主流,若干年之后的今天,当我们面对着微软的这个经典之笔,内心充满着敬意,那些曾经的记忆,可以说代表着二十年前曾经的辉煌……
        向经典致敬,或许是老一代程序员内心里面难以释怀的感受。互联网大行其道的今天,我们期待着MFC技术能够恢复其曾经的辉煌,或许这个期待会永远成为一种“梦想”,或许一切皆有可能……
        我们希望这个版块可以很好的适配Web时代,期待更好的互联网技术能够使得MFC技术框架得以重现活力,……

试试用AI创作助手写篇文章吧