我有一个带有指向对象的const指针的结构。它是const以便pointer不会改变,我不希望对象保持不变。我想在该对象中调用一个非常量函数,因此收到以下错误:errorC2662:'my_namespace::MyClass::myFunc':cannotconvert'this'pointerfrom'constmy_namespace::MyClass'to'my_namespace::MyClass&'ConversionlosesqualifiersstructMyStruct{MyStruct(constMyClass*init_my_class_ptr);constMyC
这是我关于堆栈溢出的第一篇文章,我希望将来能加入社区。我正在为ADT类编写哈希表实现;我的大部分方法都在作业范围内达到了标准,但这让我很伤心。在这个我一直用来测试我编写的各种函数的测试应用程序中,我收到错误“errorC2662:'customer::getPhone':cannotconvert'this'ponterfrom'constcustomer'to'customer&'引用行“光标=find_ptr(entry.getPhone());”和“list_head_insert(data[hash(entry.getPhone())],entry);”我的函数实现代码如下:t
我正在尝试重载c++operator==但我遇到了一些错误...错误C2662:“CombatEvent::getType”:无法将“this”指针从“constCombatEvent”转换为“CombatEvent&”这个错误在这一行if(lhs.getType()==rhs.getType())见下面的代码:classCombatEvent{public:CombatEvent(void);~CombatEvent(void);enumCombatEventType{AttackingType,...LowResourcesType};CombatEventTypegetType(