出错: error C2678: binary '==' : no operator defined which takes a left-hand operand of type???

linxin0923 2008-07-28 11:23:11
书上的例子,应该没有敲错,报错:
d:\program files\microsoft visual studio\myprojects\ex15a\student.h(35) : error C2039: 'm_strName' : is not a member of 'CString'
d:\program files\microsoft visual studio\vc98\mfc\include\afx.h(368) : see declaration of 'CString'
d:\program files\microsoft visual studio\myprojects\ex15a\student.h(35) : error C2039: 'm_nGrade' : is not a member of 'CString'
d:\program files\microsoft visual studio\vc98\mfc\include\afx.h(368) : see declaration of 'CString'
d:\program files\microsoft visual studio\myprojects\ex15a\student.h(48) : error C2678: binary '==' : no operator defined which takes a left-hand operand of type 'const class CStudent' (or there is no acceptable conversion)
Error executing cl.exe.

相关的程序代码如下:
#ifndef _INSIDE_VISUAL_CPP_STUDENT
#define _INSIDE_VISUAL_CPP_STUDENT
class CStudent : public CObject
{
DECLARE_DYNAMIC(CStudent)
public:
CString m_strName;
int m_nGrade;


CStudent()
{
m_nGrade = 0;
}


CStudent(const char* szName, int nGrade) : m_strName(szName)
{
m_nGrade = nGrade;
}

CStudent(const CStudent& s) : m_strName(s.m_strName)
{
m_nGrade = s.m_nGrade;
}

const CStudent& operator = (const CStudent& s)
{
m_strName = s.m_strName;
m_nGrade = s.m_nGrade;
}

BOOL operator == (const CString& s) const
{
if((m_strName == s.m_strName) && (m_nGrade == s.m_nGrade))
{

return TRUE;
}
else
{
return FALSE;
}
}

BOOL operator != (const CStudent& s) const
{
return !(*this == s);
}

#ifdef _DEBUG
void Dump(CDumpContext& dc) const;
#endif
};




#endif


请指点,谢谢谢谢!!!!!!!!!!!!!!!!!!!!
...全文
3247 10 打赏 收藏 转发到动态 举报
写回复
用AI写文章
10 条回复
切换为时间正序
请发表友善的回复…
发表回复
songqianqian87 2012-05-29
  • 打赏
  • 举报
回复
看看 我想看结果啊
luyi9798 2011-12-19
  • 打赏
  • 举报
回复
kankana
ruoruodudu 2011-03-29
  • 打赏
  • 举报
回复
研究下
普通网民 2010-08-08
  • 打赏
  • 举报
回复
z7049627 2010-08-04
  • 打赏
  • 举报
回复
111
qhdhotcai 2010-07-27
  • 打赏
  • 举报
回复
kankan
THth622 2009-09-30
  • 打赏
  • 举报
回复
kankan
su8844 2009-07-15
  • 打赏
  • 举报
回复
这就行
linxin0923 2008-07-28
  • 打赏
  • 举报
回复
可以了,嘻嘻
ouyh12345 2008-07-28
  • 打赏
  • 举报
回复
BOOL operator == (const CString& s) const
??

应该是
BOOL operator == (const CStudent& s) const
笔记本的风扇控制 ---------------------------------------- 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

19,468

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC 图形处理/算法
社区管理员
  • 图形处理/算法社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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