Hi, I have created a generic linked list in which different objects can be added to a list as long as they inherit from my object class. My problem is this:
I am able to add nodes and find nodes etc. but I can't figure out how to return an instance of an Object which has been added.
Below shows the code I am having trouble with (although there are many different instances of this problem, they can hopefully be resolved through this one instance being solved):
int Bank::customerSearch(unsigned int custNum)
{
int i;
for(i = 0; i < theCustomers.size(); ++i)
{
Customer c = theCustomers.at(i); //here is my problem
if(c.getCustNum() == custNum)
{
return i;
}
}
return -1;
}
When I try to assign the customer instance my program breaks because in my list the at() function is currently returning an Object reference as opposed to a Customer reference. I need to somehow return a reference to a Customer (or Account or Mortgage) instead so that it works similar to the at() function in a vector.
I have attached the header file and cpp file that I use for my linked list.
Thanks