/* Now I give myself the ability to promote an employee */ void employee::promote(string newp) { cout << fname << " " << lname << " promoted from " << position << " to " << newp << "\n"; position = newp; } /* Person number 8 in the vector was created with "new employee", the object is an employee, but the compiler rejects this */ A[8]->promote("senior person"); /* because the vector was declared as a vector of pointers to persons, and person objects do not have promote methods. The type cast tells the compiler "just pretend this is a pointer to an employee, and do what you would do if it really were, so this works */ ((employee *)A[8])->promote("senior person"); /* but it is very dangerous. I could easily type */ ((employee *)A[14])->promote("senior person"); /* and nobody would know the difference. If we're lucky it will crash the program */