Well, just to close out the post:
I got it working after making the operator into a friends funtion in the virtual parent class, Employee:
friend bool operator ==(Employee emp1, Employee emp2)
{
if (emp1.empNum == emp2.empNum)
return true;
else
return false;
}
In the main part of the program I create a temp object of derived class Engineer, set the empNumber and then do a simple comparison of the pointer array to the temp object:
case 6:
int tempNum;
bool found; int foundCount;
int j;
found=false;
system("cls");
cout << " Input the employee Number: ";
cin>>tempNum;
tmpEmpRec->setNum(tempNum);
j=0;
do
{
if(*tmpEmpRec == *(employee[j]))
{
found = true;
foundCount = j;
};
j++;
}while ((!found)&& j<empCount);
__________________
"Of all tyrannies, a tyranny exercised for the good of its victims may be the most oppressive. It may be better to live under robber barons than under omnipotent moral busybodies. The robber baron's cruelty may sometimes sleep, his cupidity may at some point be satiated; but those who torment us for our own good will torment us without end, for they do so with the approval of their own conscience." – C. S. Lewis
The ONLY sponsors we have are YOU!
Please Donate!
|