0
  1. Write a function bool DeleteRecord(List *list, T record) that can be used to delete record from a linked list. You can use it to delete record in Student list or Book list. If delete from Student list, use id to find student and if delete from Book list, use call number to find book. The record variable will store id or call number of the object to be deleted. The function will return true if successfully delete and false if student cannot be found in the list.

this is the function:

template <class T>
bool DeleteRecord(List<T> *list, T record)
{
T temp, check_ls;
bool del = false;

cout << "\nDeleting record......";


strcpy(temp, record);
for (int i = 1; i <= (*list).size(); i++)
{
    (*list).get(i, check_ls);
    if (check_ls == temp){
        (*list).remove(i);
        del = true;
        break;
    }
}

if (del){ return true; }
else { return false; }
}

this if findID:

string findID(){

string id;
bool valid = false;

while (!valid){
    cout << "\nEnter ID of Student: ";
    cin >> id;
    valid = true;

    if (id.length() != 7)
    {
        cout << "\nError! Enter 7 digits";
        id = "";
        valid = false;
    }
    else
    {
        if (!alldigit(id))
        {
            valid = false;
            cout << "\nError! Enter digit only.";
        }
    }
}
return id;
}

this is my code so far (main.cpp)

int main(){
        system("cls");
        cout << "Delete Record\n";
        //cout << findID().c_str();
        id=findID();
        cout << id;

        if (DeleteRecord(stulist, id)){ cout << "Success! Record deleted.\n"; }
        else { cout << "\n\nError! No such record.\n"; }

        cout << "\nInfo: " << (*stulist).size() << " record(s) remaining.\n\n";
        system("pause");
        return 0;
        }

there is a problem when i call the DeleteRecord function. it say no instance of function template matches the argument list. Anyone can help me to solve this problem?

Simon Lew
  • 1
  • 1
  • 2
  • 1
    Hello and welcome to SO. Please take the [tour](https://stackoverflow.com/tour) and read the [help page](https://stackoverflow.com/help). Start by reading one of [these C++ books](https://stackoverflow.com/questions/388242/the-definitive-c-book-guide-and-list). – Ron Jul 20 '17 at 04:56
  • When reading the help pages, be sure to focus on understanding how to create a [mcve]. – StoryTeller - Unslander Monica Jul 20 '17 at 05:42
  • Where is `stulist` declared? What is its type? Where is `id` declared? – Ajay Brahmakshatriya Jul 20 '17 at 08:55

1 Answers1

0

Your function is like

bool DeleteRecord(List<T> *list, T record)

and your arguments are wrong. I guess its a List that is causing troubles. Try deleting that *.

Azeem
  • 11,148
  • 4
  • 27
  • 40
Sv Sv
  • 325
  • 3
  • 12