Consider the following class declaration class patientrecord

Consider the following class declaration: class patient_record {public: int age; string name; double service_charge;}; Implement the void function \"delete_rec\" which deletes a record with the name that matches key from the dynamic array called \"DB\". Rememeber, to check to see if DB is empty because you cannot delete from an empty array. Consider the following prototype to help you write (code) this function: void delete_rec(patient_record *DB, const string &key;, int & count) All members of a structure are private by default. True False The new operator returns a pointer to newly allocated memory. True False

Solution

Here is the method delete_rec() for you:

void delete_rec(patient_record *DB, const string &key, int &count)
{
if(DB != NULL)
{
for(int i = 0; i < count; i++)
if((DB+i)->name == key)
{
for(int j = i+1; j <count; j++)
*(DB) = *(DB+i);
count--;
break;
}
}
}

All members of a structure are private by default. True. The structure members if not specified explicitly are private.

The new operator returns a pointer to newly allocated memory. True. Its allocates the required memory and will return the pointer to the memory location.

 Consider the following class declaration: class patient_record {public: int age; string name; double service_charge;}; Implement the void function \

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site