【问题标题】:Linked List no match for operator* compiler error链接列表与 operator* 编译器错误不匹配
【发布时间】:2011-05-05 21:56:08
【问题描述】:

我正在尝试使用将十六进制值接受到链接列表中的对象制作一个基本的 C++ 程序,并允许用户添加/乘以列表中的值。问题是我在对象的乘法区域中遇到编译器错误。代码如下:

void LList::Multi() {
  element new_input;
  element temp;
  element temp1;
  cout << "Please enter the number you would like to multiply." <<endl;
  new_input = Read_Element();
  temp = head −> data;
  temp1 = (temp * new_input);
  head −> data = temp1;
}

这是我得到的错误: LList.cpp:在成员函数 void LList::Multi():LList.cpp:77 中:错误:在 temp * new_input 中与 operator* 不匹配

我只使用 库,非常感谢任何输入。

【问题讨论】:

  • 你好,@deadly.foxie。欢迎来到堆栈溢出!什么是element

标签: c++ linked-list compiler-errors no-match


【解决方案1】:

如果您想对element 类型的对象使用* 运算符,则需要重载该运算符。您得到的错误是告诉您您还没有编写可用于两个 element 对象的运算符重载函数。

【讨论】:

  • 感谢您的回复,我已经意识到我做错了什么。愚蠢的我试图增加刺痛。
猜你喜欢
  • 1970-01-01
  • 2011-10-06
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2011-12-10
  • 2013-07-31
  • 2014-02-26
  • 2019-02-17
相关资源
最近更新 更多