Here I have a base class Rock, which can have random number of gold amount.
If after a rock object is created, I check how many gold is inside
If there is less than 71 gold, I have to change it to a ValuableRock
If there is more than 70 gold, I have to change it to a PreciousRock
Rocks uncracked is still ordinary Rock
but once cracked, it has to be either ValuableRock or PreciousRock
and by calling checkPrice(), it should print out the corresponding price

I tried to type cast the pointer type (method 1) but it does not call the corresponding function
then I tried to delete the object (method 2) and create an appropriate object using the same base class pointer, this way the correct checkprice is called, but since it creates a new object, the gold amount is another random one

Can anyone provide a good solution for me so that
1. I can access all kind of rock classes using an array of pointers
2. gold must rand() in the base class, not in the main() then assign appropriate class of xxxRocks construction because not all Rocks are cracked at time of creation
3. class hierarchy Rock, ValuableRock, PreciousRock must be maintained. (I know there is solution that can be done within a single class)