c++linked-listcompiler-errorsno-match

Linked List no match for operator* compiler error


I'm trying to make a basic C++ program using objects that accepts a hex value into a linked list, and allows the user to add/multiply the values in the list. The problem is that I'm getting a compiler error in the multiplication area of my object. Here's the code:

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;
}

And here is the error I'm getting: LList.cpp: In member function void LList::Multi():LList.cpp:77: error: no match for operator* in temp * new_input

I'm only using the <iostream> <stdlib.h> and <string> libraries, any input would be very much appreciated.


Solution

  • If you want to use the * operator on objects of type element, you need to overload that operator. The error you're getting is telling you that you haven't written an operator-overloading function that can be used on two element objects.