This may sound dumb but I have a project where I need to create and delete pointers in if/else statements. Is it possible?
It's basically regarding manager's shift change so every time there will only be one manager so I thought it would be easier if i could create pointer when the manager starts the shift and delete when the manager ends in a loop.
Basic outline:
(Retrieving from a text file)
if manager in
create pointer to class
retrieve data
if manager out
delete pointer
So when printing the final audit reports I can just point to the same location.
Not 100% sure what you're asking, but it seems like you want to clone the manager with a pointer of the same class...
1 2 3 4 5 6 7 8 9 10 11 12
Manager inputman;
if (inputman.in())
{
Manager *genericptr=&inputman;
while (genericptr->getdata())
{
if (genericptr->out())
{
delete genericptr;//this works but it'll delete both genericptr and inputman
}
}
}